Now that the Jags run successfully in kPercentVbus mode as well as kVoltage mode as long as all the Encoder related initializations are commented out, I am investigating what exactly caused this. I have isolated the culprit. It looks like all the encoder initializations are fine except for the SetPID calls. So basically, the following code doesn't work until I comment out the CULPRIT_CODE lines. Note that the Jags are initialized to kPercentVbus mode. Kp is 15.0, both Ki and Kd are zeros. What could have caused this?
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::kPercentVbus),
m_jagRight(CANID_RIGHT_JAG, CANJaguar::kPercentVbus),
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);
#ifdef _CULPRT_CODE
m_jagLeft.SetPID(DRIVE_KP, DRIVE_KI, DRIVE_KD);
m_jagRight.SetPID(DRIVE_KP, DRIVE_KI, DRIVE_KD);
#endif
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);
}
}
};