Go to Post No. This is CD, take the threads and their topics seriously. - pwnageNick [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 08-03-2016, 00:34
PredaFran PredaFran is offline
Amateur Programmer
AKA: Francisco
FRC #5285 (Sea Kings Robotics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: California
Posts: 25
PredaFran is an unknown quantity at this point
Problems with USB camera(Lifecam)

Hey there,
We have been experiencing problems trying to integrate the USB camera into our actual driving code. The LifeCam code disables the driving code, specifically the motor controllers, and we are not exactly sure of why. What we have been trying to troubleshoot it for the last week, without any considerable success. Any help is greatly appreciated.




Code:
#include "WPILib.h"
/**
 * This is a demo program showing the use of the RobotDrive class.
 * The SampleRobot class is the base of a robot application that will automatically call your
 * Autonomous and OperatorControl methods at the right time as controlled by the switches on
 * the driver station or the field controls.
 *
 * WARNING: While it may look like a good choice to use for your code if you're inexperienced,
 * don't. Unless you know what you are doing, complex code will be much more difficult under
 * this system. Use IterativeRobot or Command-Based instead if you're new.
 */
class Robot: public SampleRobot
{
	 // robot drive system
	RobotDrive ArcadeRobot;
	Joystick joy, joy2;
	Servo ServoX, ServoY;
	double servoIn, servoIn2;
	VictorSP intake;
	TalonSRX flywheel;
	USBCamera cam0;

public:
	Robot() :
		ArcadeRobot(0,1),
		cam0(0),
		joy(0),
			joy2(1),
			ServoX(5),
			ServoY(4),
			intake(3),
			flywheel(2)

	{
		    cam0.SetWhiteBalanceAuto();
		    cam0.SetExposureAuto();
			flywheel.SetSafetyEnabled(false);
			intake.SetSafetyEnabled(false);
			ArcadeRobot.SetExpiration(0.1);
	}

	/**
	 * Runs the motors with arcade steering.
	 */
	void OperatorControl()
	{
		while (IsOperatorControl() && IsEnabled())
		{

			if (joy2.GetRawButton(3))
			{
				//ShootLowGoal();
				intake.Set(-1.0);
			}
			if (joy2.GetRawButton(5))
			{
				//ShootHighGoal();
				intake.Set(1.0);
			}
			if (joy2.GetRawButton(4))
			{
				//ShootLowGoal();
				flywheel.Set(-1.0);
			}
			if (joy2.GetRawButton(6))
			{
				//ShootHighGoal();
				flywheel.Set(1.0);
			}

			servoIn = (joy.GetY() +1)*0.5;
			servoIn2 = (joy.GetX() +1)*0.5;
			ServoX.Set(servoIn);
		    ServoY.Set(servoIn2);
		    ArcadeRobot.ArcadeDrive(joy2);
		    Wait(0.005);
		}
	}







};

START_ROBOT_CLASS(Robot)
Reply With Quote
  #2   Spotlight this post!  
Unread 08-03-2016, 07:08
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Problems with USB camera(Lifecam)

You're declaring cam0 at the end of the list of Robot variables. Does it work if you move the cam0(0) line to the end of the initializations, after flywheel(w)?
Reply With Quote
  #3   Spotlight this post!  
Unread 08-03-2016, 20:55
PredaFran PredaFran is offline
Amateur Programmer
AKA: Francisco
FRC #5285 (Sea Kings Robotics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: California
Posts: 25
PredaFran is an unknown quantity at this point
Re: Problems with USB camera(Lifecam)

Alan,
We tried what you said but we still are getting the following errors
  • For cam(0)
no matching function for call to 'USBCamera::USBCamera(int)'
  • For Joystick joy, joy2
Joystick Robot::joy' [-Wreorder]
  • For USBCamera cam0
'Robot::cam0' will be initialized after [-Wreorder]

Last edited by PredaFran : 09-03-2016 at 14:47.
Reply With Quote
  #4   Spotlight this post!  
Unread 08-03-2016, 23:20
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Problems with USB camera(Lifecam)

It sounds like you might have fumbled some of the commas or semicolons when you moved the cam0(0) line. Can you post the part of the code that you modified?

I'm assuming you retyped the errors into the post by hand rather than copying them, because of the missing zero in cam(0). If you actually did copy and paste, then it seems you introduced a misspelling it when you moved it in your code.
Reply With Quote
  #5   Spotlight this post!  
Unread 09-03-2016, 14:45
PredaFran PredaFran is offline
Amateur Programmer
AKA: Francisco
FRC #5285 (Sea Kings Robotics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: California
Posts: 25
PredaFran is an unknown quantity at this point
Re: Problems with USB camera(Lifecam)

I have double checked the comas and semicolons and nothing seems weird, but you are welcome to check if you want to.


Code:
#include "WPILib.h"

class Robot: public SampleRobot
{
	 // robot drive system
	RobotDrive ArcadeRobot;
	Joystick joy, joy2;
	Servo ServoX, ServoY;
	double servoIn, servoIn2;
	VictorSP intake;
	TalonSRX flywheel;
	USBCamera cam0;

public:
	Robot() :
		ArcadeRobot(0,1),
		joy(0),
		joy2(1),
		ServoX(5),
		ServoY(4),
		intake(3),
		flywheel(2),
		cam0(0)

	{
		    cam0.SetWhiteBalanceAuto();
		    cam0.SetExposureAuto();
			flywheel.SetSafetyEnabled(false);
			intake.SetSafetyEnabled(false);
			ArcadeRobot.SetExpiration(0.1);
	}

	/**
	 * Runs the motors with arcade steering.
	 */
	void OperatorControl()
	{
		while (IsOperatorControl() && IsEnabled())
		{

			if (joy2.GetRawButton(3))
			{
				//ShootLowGoal();
				intake.Set(-1.0);
			}
			if (joy2.GetRawButton(5))
			{
				//ShootHighGoal();
				intake.Set(1.0);
			}
			if (joy2.GetRawButton(4))
			{
				//ShootLowGoal();
				flywheel.Set(-1.0);
			}
			if (joy2.GetRawButton(6))
			{
				//ShootHighGoal();
				flywheel.Set(1.0);
			}

			servoIn = (joy.GetY() +1)*0.5;
			servoIn2 = (joy.GetX() +1)*0.5;
			ServoX.Set(servoIn);
		    ServoY.Set(servoIn2);
		    ArcadeRobot.ArcadeDrive(joy2);
		    Wait(0.005);
		}
	}







};

START_ROBOT_CLASS(Robot)
Reply With Quote
  #6   Spotlight this post!  
Unread 12-03-2016, 09:39
codedr codedr is offline
Registered User
FRC #0537
Team Role: Mentor
 
Join Date: Mar 2010
Rookie Year: 2009
Location: Wisconsin
Posts: 70
codedr will become famous soon enoughcodedr will become famous soon enough
Re: Problems with USB camera(Lifecam)

Shouldn't the USBCamera constructor called with cam0("cam0", true) ?
Reply With Quote
  #7   Spotlight this post!  
Unread 12-03-2016, 23:11
The Lucas's Avatar
The Lucas The Lucas is offline
CaMOElot, it is a silly place
AKA: My First Name is really "The" (or Brian)
FRC #0365 (The Miracle Workerz); FRC#1495 (AGR); FRC#4342 (Demon)
Team Role: Mentor
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Dela-Where?
Posts: 1,564
The Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond reputeThe Lucas has a reputation beyond repute
Send a message via AIM to The Lucas
Re: Problems with USB camera(Lifecam)

Quote:
Originally Posted by PredaFran View Post
Alan,
We tried what you said but we still are getting the following errors
  • For cam(0)
no matching function for call to 'USBCamera::USBCamera(int)'
Quote:
Originally Posted by codedr View Post
Shouldn't the USBCamera constructor called with cam0("cam0", true) ?
Only USBCamera constructor is
USBCamera (std::string name, bool useJpeg)
http://first.wpi.edu/FRC/roborio/rel...USBCamera.html

Are you just trying to view the cam on dashboard, or are you trying vision processing? If you just want to view on dashboard, it is probably easier to just use CameraServer.
http://first.wpi.edu/FRC/roborio/rel...eraServer.html
__________________
Electrical & Programming Mentor ---Team #365 "The Miracle Workerz"
Programming Mentor ---Team #4342 "Demon Robotics"
Founding Mentor --- Team #1495 Avon Grove High School
2007 CMP Chairman's Award - Thanks to all MOE members (and others) past and present who made it a reality.
Robot Inspector
"I don't think I'm ever more ''aware'' than I am right after I burn my thumb with a soldering iron"
Reply With Quote
  #8   Spotlight this post!  
Unread 19-03-2016, 20:35
snekiam snekiam is offline
Registered User
FRC #3322 (Eagle Imperium)
Team Role: Programmer
 
Join Date: Dec 2015
Rookie Year: 2010
Location: SE Michigan
Posts: 88
snekiam has a spectacular aura aboutsnekiam has a spectacular aura aboutsnekiam has a spectacular aura about
Re: Problems with USB camera(Lifecam)

Check your CPU usage. Ours skyrocketed when we enabled the camera, no matter the resolution / fps. We had two incidents on the field when we could not drive, but other motors worked just fine. It turns out we were hovering at 110% cpu usage for all of our matches, and that somehow disabled the drivetrain. Our rudimentary solution was to use a raspberry pi with MJPG streamer to get the feed to our driverstation.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:29.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi