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)