public abstract class MotionController implements Subsystem {
protected DoubleConsumer output;
protected final PIDSensor sensor;
protected double setpoint;
protected double absoluteTolerance;
......
public MotionController(PIDSensor sensor, DoubleConsumer output) {
this.sensor = sensor;
setOutput(output);
enable = false;
overridden = false;
absoluteTolerance = Double.MIN_VALUE; // Nonzero to avoid floating point errors
......
}
/**
* True if the error in the motion controller is less than the tolerance of the
* motion controller.
*
* @return
*/
public boolean onTarget() {
return Math.abs(getError()) <= absoluteTolerance;
}
......
}
the onTarget() method only returns true IF our error (offset from the target point) is less than or equal to absoluteTolerance = Double.MIN_VALUE, which will never happen. absoluteTolerance needs to be increased to a reasonably small decimal value or tuned based on the required tolerance of each individual subsystem.
In
MotionController.java
:the
onTarget()
method only returns true IF our error (offset from the target point) is less than or equal toabsoluteTolerance = Double.MIN_VALUE
, which will never happen.absoluteTolerance
needs to be increased to a reasonably small decimal value or tuned based on the required tolerance of each individual subsystem.