
23-01-2011, 02:45
|
|
National Instruments
AKA: Joe Hershberger
 FRC #2468 (Appreciate)
Team Role: Mentor
|
|
Join Date: May 2008
Rookie Year: 1997
Location: Austin, TX
Posts: 1,006
|
|
|
Re: setX() not working
Quote:
Originally Posted by JewishDan18
Ok, so I set the number of ticks, and setSpeed still does not seem to work. Here's what I've written.
Code:
CANJaguar jag;
public void robotInit() {
try {
jag = new CANJaguar(4);
jag.setPID(1, 1, 0);
jag.setSpeedReference(CANJaguar.SpeedReference.kQuadEncoder);
jag.changeControlMode(CANJaguar.ControlMode.kSpeed);
jag.configEncoderCodesPerRev(100);
jag.enableControl();
} catch (Exception e) {
e.printStackTrace();
}
}
Code:
public void teleopPeriodic() {
try {
jag.setX(10);
System.out.println(jag.getSpeed() + " " + jag.getOutputVoltage() +
" " + jag.getOutputCurrent() + " " +
jag.getTemperature() + " " + jag.isAlive() +
" " + jag.isSafetyEnabled());
} catch (Exception e) {
e.printStackTrace();
}
}
During Current or Voltage control, the encoder reads fine. But in Speed control, no signal to drive is sent to the jaguar (light is yellow, both outputs are 0, as is the speed). Is there something I'm forgetting to set? Thanks.
|
The code looks OK at first glance. My guess would be that your PID constants are too small. Try increasing the P at least to see if that has any impact.
-Joe
|