Our team has been using Victors for a number of years. We finally want
to embrace
Jaguar and try CAN bus for this year. We've got 4 Black Jaguars and a 2CAN (not V2 though). I quickly written some simple code
to test the Jaguars but it doesn't work. There must be some sample code written somewhere for CANJaguar on 2CAN. Would somebody point me
to it?
To summarize what my simple code does:
Code:
class MyRobot: public SimpleRobot
{
private:
CANJaguar m_jagLeft;
CANJaguar m_jagRight;
Joystick m_leftStick;
Joystick m_rightStick;
public:
MyRobot():
m_jagLeft(CANID_LEFT_JAG, CANJaguar::kSpeed),
m_jagRight(CANID_RIGHT_JAG, CANJaguar::kSpeed),
m_leftStick(JOYSTICK_LEFT),
m_rightStick(JOYSTICK_RIGHT)
{
m_jagLeft.SetSpeedReference(CANJaguar::kSpeedRef_QuadEncoder);
m_jagRight.SetSpeedReference(CANJaguar::kSpeedRef_QuadEncoder);
m_jagLeft.SetPositionReference(CANJaguar::kPosRef_QuadEncoder);
m_jagRight.SetPositionReference(CANJaguar::kPosRef_QuadEncoder);
m_jagLeft.SetPID(DRIVE_KP, DRIVE_KI, DRIVE_KD);
m_jagRight.SetPID(DRIVE_KP, DRIVE_KI, DRIVE_KD);
m_jagLeft.ConfigEncoderCodesPerRev(DRIVE_ENCODER_CODES_PER_REV);
m_jagRight.ConfigEncoderCodesPerRev(DRIVE_ENCODER_CODES_PER_REV);
m_jagLeft.EnableControl();
m_jagRight.EnableControl();
}
....
....
....
void OperatorControl(void)
{
while (IsOperatorControl())
{
m_jagLeft.Set(-m_leftStick.GetY());
m_jagRight.Set(-m_rightStick.GetY());
Wait(0.005);
}
}
};
I printed the joystick values
to dsLCD and I got reasonable values when reading the sticks. So it means the m_jagXXXX.Set() is not doing anything. All the jags are assigned correct IDs (2 and 3) and have firmware version 92 on them. The 2CAN has a green light and I can access its web page in my browser on
http://10.4.92.10. I even plugged in the serial cable directly
to one of the jags and ran bdc-comm-92.exe tool. The tool enumerated saw the jag ID 2 and 3 and I was able
to set some values on each of the jags and made them turn. That means the CAN bus is wired properly and the 2CAN interface with the CAN bus successfully (through the web interface). The only thing I am unsure is if the cRIO can communicate with the 2CAN. I assume the cRIO knows how
to communicate with the 2CAN since I have imaged the cRIO with "2CAN" selected, so the 2CAN driver should be running. And I am also assuming the cRIO will communicate with the 2CAN using 10.xx.xx.10 as its IP address. What else did I miss?