After much troubleshooting trying to figure out why Servo.get() was returning 0.0 for any servo position other than 1.0, I noticed the following code in edu.wpi.first.wpilibj.PWM:
public double getPosition() {
int value = getRaw();
if (value < getMinNegativePwm()) {
return 0.0;
} else if (value > getMaxPositivePwm()) {
return 1.0;
} else {
return (value - getMinNegativePwm()) / getFullRangeScaleFactor();
}
}
Notice the final return statement. value, getMinNegativePwm(), and getFullRangeScaleFactor() are all of type int. Would this not cause the integer division to truncate to 0 for any result less than 1? I checked the C++ version of the same function, and sure enough, the numerator and denominator of the fraction are cast to float before the division.