Quote:
Originally Posted by mbushroe
how about a code sample to connect the cRIO to the internal PID of the Jaguar? ... We would like to use the internal Jaguar PID, but have not yet found a way to control it through the robot.
|
You can look at our team's 2011 code for an example if you like - it's available at
http://code.google.com/p/robovikings-2607/. In particular look at the LogomotionDriveTrain class.
Basically, in robotInit() you would do something similar to this:
Code:
public void robotInit() {
try {
m = new CANJaguar(2); // change 2 to match the CAN id of the Jag
m.changeControlMode(CANJaguar.ControlMode.kSpeed);
m.setSpeedReference(CANJaguar.SpeedReference.kEncoder);
m.configEncoderCodesPerRev(240); // change 240 to match your encoder
m.setPID(.350, .004, .001); // change gains to whatever you need based on tuning
m.enableControl();
} catch (Exception e) {
...
}
}
Then in the autonomous or teleop methods use the m.setX() to set the speed you want the motor to run at.
Quote:
Originally Posted by Ether
... I don't have access to an FRC Java installation so I can't confirm whether this class supports the serial-to-CAN interface.
|
The WPILib classes for CAN support in Java and C++ (and Labview for that matter) are all independent of the type of CAN interface used (serial or 2CAN). The actual comms are handled via the "plugin" (BlackJag plugin for serial, or 2CAN plugin for the 2CAN) and the WPILib routines communicate through those plugins.
Hope this helps!
- Ron
Team #2607 controls mentor