View Single Post
  #1   Spotlight this post!  
Unread 01-19-2016, 08:02 PM
Prodigi3277 Prodigi3277 is offline
Registered User
FRC #3277
 
Join Date: Jan 2016
Location: Minnesota
Posts: 2
Prodigi3277 is an unknown quantity at this point
Can't use joystick when using two CAN Jaguars

We are currently only able to control one CAN Jaguar in our code. Adding a second CANJaguar object creates a problem where the joystick values are not getting read into the robot. Even with the second CANJaguar (called m_JaguarLeft below) only created and initialized (no methods being called on it), and the robot stops responding to the joystick. The joystick is seen by the drive station, and the values are being displayed on all of the appropriate views.

Code:
class Robot: public SampleRobot
{
	RobotDrive myRobot; // robot drive system
	Joystick stick; // only joystick
	CANJaguar m_JaguarRight, m_JaguarLeft;
public:
	Robot() :
		myRobot(0, 1),	// initialize the RobotDrive to use motor controllers on ports 0 and 1
		stick(0),
		m_JaguarRight(3),
		m_JaguarLeft(2)
	{
		//LiveWindow *lw;

		m_JaguarRight.SetPercentMode(CANJaguar::QuadEncoder, 360);
		m_JaguarRight.EnableControl();
		m_JaguarRight.Set(0.0f);

		m_JaguarLeft.SetPercentMode(CANJaguar::QuadEncoder, 360);
		m_JaguarLeft.EnableControl();
		m_JaguarLeft.Set(0.0f);
		myRobot.SetExpiration(0.1);
	}
	void Disabled()
	{
		while(IsDisabled()){}
	}


	void RobotInit()
	{
		//lw = LiveWindows::GetInstance();

	}
	/**
	 * Runs the motors with arcade steering.
	 */
	void OperatorControl(void)
	{
		myRobot.SetSafetyEnabled(true);
		while (IsOperatorControl())
		{
			m_JaguarRight.Set(stick.GetY()); // drive with arcade style (use right stick)
			m_JaguarLeft.Set(stick.GetY());
			Wait(0.005);				// wait for a motor update time
		}
	}

};
We are getting our new programmers introduced into FRC, and are moving to C++ coding this year. Everyone is at a loss as to what is going on with this not working.
Reply With Quote