Jaguars do not work except in percent vbus mode

We are attempting to use closed-loop encoder control with our Jaguars this year. When we hook our CAN network up to a computer, we can use BDC-COMM to set output values in RPM and the motors run correctly.

When we try to control the Jaguars from Java, we can’t get it to work. We can control the Jaguars in the percent voltage mode just fine (that’s the -1 to 1 output mode). When we switch to voltage, speed, or current mode, they don’t work. The motors don’t move, the light on the Jaguar stays solid yellow, and the voltage output according to the code is 0.

Our code is in teleopPeriodic() and looks like this:

try{
  leftMotor.changeControlMode(CANJaguar.ControlMode.kVoltage);
  leftMotor.setX(6);
  // a bunch of printlns for debugging
}catch(CANTimeoutException ex){
  ex.printStackTrace();
}

No exceptions, nothing but yellow lights on the Jaguar. Nothing.

Any ideas?

This bit my team, too. In anything but PercentVBus, a few extra calls have to be made. You’re using voltage, so the Jaguars can do the referencing internally, so no external references have to be set.

However, for any control mode that needs to go to a setpoint, you need to set and tune the Jaguars’ internal PID loop. In addition, you have to manually enable control. Use something like


jag.setPID(1,1,0);
jag.enableControl();

without the made-up numbers. I’d recommend the BDC-COMM utility to tune the loop, as it drastically simplifies things.