Quote:
Originally Posted by Gigakaiser
For example, if you know the robot is straight and you want to turn 30 degrees (but your gyro drift is adding up), you could turn to gyro.getAngle() + 30.0. Another solution, as MagiChau wrote, is to reset the gyro if you know where your robot is pointed.
|
public void operatorControl() {
double lastAngle = 0;
double newAngle =0;
double realAngle = 0;
gyro.reset();
while (isEnabled() && isOperatorControl()) {
double move = y.getY();
motor.set(move/5);
if (move > 0.01 || move < -0.01) {
newAngle = gyro.getAngle();
lastAngle = realAngle;
} else {
realAngle = newAngle + lastAngle;
gyro.reset();
}
System.out.println(realAngle);
System.out.println(move);
Timer.delay(0.05);
}
}
do you think this will work ?