View Single Post
  #5   Spotlight this post!  
Unread 02-02-2012, 10:12
omalleyj omalleyj is offline
Registered User
AKA: Jim O'Malley
FRC #1279 (Cold Fusion)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2008
Location: New Jersey
Posts: 132
omalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to behold
Re: New to FRC programming... How does this look?

Code:
double angle = 0;

do {
     drivetrain.drive(0.0, 0.15); //TURN
     drivetrainTimer.delay(0.5);
     angle += gyro.getAngle(); //
     gyro.reset();
     log("Gyro reads "+angle);
}while(angle<90); //Keep going in increments of .15 until gyro
I don't use the standard drive() methods, but IIRC the first value is the forward speed and the second the turning offset speed-wise, not an angle. So unless you know 0.5 second increments is going to end up close to 90, you could be over by a bit.
And only reset your gyro when you need to, and not when its moving. You want to stop and wait a little so that you have a steady zero value.

Last edited by omalleyj : 02-02-2012 at 10:17.
Reply With Quote