Thread: Gyro Help
View Single Post
  #2   Spotlight this post!  
Unread 15-01-2015, 19:48
curtis0gj curtis0gj is offline
Registered User
FRC #5033 (Beavertronics)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Canada
Posts: 121
curtis0gj will become famous soon enough
Re: Gyro Help

Quote:
Originally Posted by Tanis View Post
The first problem is that you are resetting the gyro in every iteration of your loop. Thus the angle variable is always going to contain the number of degrees that you have turned since the last iteration of the loop (plus 90 degrees).

Unless you are turning really fast, you are never going to get the gyro to read a full 90 degrees.

I'm also not sure why you are adding 90 degrees to the angle each time. If you are turning in the positive direction, your angle will always be greater than 90 degrees. If you are turning in the negative direction, your angle will always be less than 90 degrees because of the above problem. Either way, the magic +90 is probably not what you intended and the stopMotor() method is not going to be called when you want it to be called.

What you probably want is to reset the gyro in the robotInit() method or before your autonomous while loop, then leave it alone.
Thanks for the help I moved the reset into the robotInit and I removed the +90. But I don't understand what I need to do to fix the stopMotor() issue you were talking about. If you don't mind elaborating it would be greatly appreciated.
Reply With Quote