I'm getting some strange results when trying to read my gyroscope. As it sits there the gyro seems to accumulate angle: it will slowly count upwards, starting at zero and gradually drifting upwards into positive values. For the life of me I can't figure out why, with the robot sitting dead still, the gyro reading does not stay at zero. Anyone else have this problem?
Gyro test loop:
Code:
// gyro test
while (this.isDisabled()) {
station.toLCDLine(3, "Gyro Test");
double sensitivity = 0.000;
//spinGyro.setSensitivity(sensitivity);
String msg = "Sensitivity " + sensitivity;
station.toLCDLine(4, msg);
msg = "Heading " + getCurrentHeading();
station.toLCDLine(5, msg)
Heading code, changes headings to plus or minus 180 degrees:
Code:
public double getCurrentHeading() {
double current = spinGyro.getAngle()%360;
if (current > 180) {
current = -(current - 360);
}
return current;
}