FourPenguins
19-02-2012, 13:30
We just ran into this, and I wanted to put out a warning to everyone else.
The JavaDoc for the PIDSubsystem class says
public void setSetpoint(double setpoint)
Sets the setpoint to the given value. If setRange(...) was called, then the given setpoint will be trimmed to fit within the range.
In testing, we almost destroyed some things on our shooter aiming mechanism when it ran past our range limits. After looking at the WPILibJ code, we found that the setSetpoint() method just passed the setpoint on to the PID Controller without checking the range limits. It's easy to override the method to saturate your setpoints yourself, but if you don't know you have to, you could get a nasty surprise.
The JavaDoc for the PIDSubsystem class says
public void setSetpoint(double setpoint)
Sets the setpoint to the given value. If setRange(...) was called, then the given setpoint will be trimmed to fit within the range.
In testing, we almost destroyed some things on our shooter aiming mechanism when it ran past our range limits. After looking at the WPILibJ code, we found that the setSetpoint() method just passed the setpoint on to the PID Controller without checking the range limits. It's easy to override the method to saturate your setpoints yourself, but if you don't know you have to, you could get a nasty surprise.