View Single Post
  #6   Spotlight this post!  
Unread 20-03-2013, 02:18
zatch bell stev zatch bell stev is offline
Registered User
FRC #2523
 
Join Date: Jan 2012
Location: vermont
Posts: 14
zatch bell stev is an unknown quantity at this point
Re: Gyro problem, please help!

Quote:
Originally Posted by Gigakaiser View Post
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 ?