This is the third year out team is using CAN, but this problem has me stumped.
We just updated the firmware on a new black jaguar (v100 from ti.com/jaguar) and assigned it board ID 1. We have a new 4-slot cRIO imaged with the NI cRIO Imaging Tool, and we are using WindRiver C++ for programming with latest workbench/WPILib update from FIRSTForge.
The jaguar worked fine when controlled manually by BDC-COMM, but when connected to the cRIO, we are getting an error in sendMessage(), CANJaguar.cpp line 460: JaguarCANDriver timed out while waiting for a response.
Here is the code we used, basically the sample IterativeRobot with everything commented out:
#include "WPILib.h"
#include "CANJaguar.h"
class BuiltinDefaultCode : public IterativeRobot
{
CANJaguar *motor;
// Local variables to count the number of periodic loops performed
UINT32 m_autoPeriodicLoops;
UINT32 m_disabledPeriodicLoops;
UINT32 m_telePeriodicLoops;
public:
BuiltinDefaultCode(void) {
printf("BuiltinDefaultCode Constructor Started
");
// Initialize counters to record the number of loops completed in autonomous and teleop modes
m_autoPeriodicLoops = 0;
m_disabledPeriodicLoops = 0;
m_telePeriodicLoops = 0;
printf("BuiltinDefaultCode Constructor Completed
");
}
/********************************** Init Routines *************************************/
void RobotInit(void) {
// Actions which would be performed once (and only once) upon initialization of the
// robot would be put here.
motor = new CANJaguar(1);
printf("RobotInit() completed.
");
}
void DisabledInit(void) {
m_disabledPeriodicLoops = 0; // Reset the loop counter for disabled mode
// Move the cursor down a few, since we'll move it back up in periodic.
printf("\x1b2B");
}
void AutonomousInit(void) {
m_autoPeriodicLoops = 0; // Reset the loop counter for autonomous mode
}
void TeleopInit(void) {
m_telePeriodicLoops = 0; // Reset the loop counter for teleop mode
}
/********************************** Periodic Routines *************************************/
void DisabledPeriodic(void) {
static INT32 printSec = (INT32)GetClock() + 1;
static const INT32 startSec = (INT32)GetClock();
// increment the number of disabled periodic loops completed
m_disabledPeriodicLoops++;
// while disabled, printout the duration of current disabled mode in seconds
if (GetClock() > printSec) {
// Move the cursor back to the previous line and clear it.
printf("\x1b1A\x1b2K");
printf("Disabled seconds: %d
", printSec - startSec);
printSec++;
}
}
void AutonomousPeriodic(void) {
m_autoPeriodicLoops++;
}
void TeleopPeriodic(void) {
// increment the number of teleop periodic loops completed
m_telePeriodicLoops++;
motor->Set(0.5);
} // TeleopPeriodic(void)
};
START_ROBOT_CLASS(BuiltinDefaultCode);
We tried switching out CAN cables, re-imaging the cRIO, and rewriting firmware on the Jaguar. Oddly, PWM worked perfectly when we tested it out, only CAN is having problems.
Thanks in advance!