View Single Post
  #2   Spotlight this post!  
Unread 28-02-2012, 00:55
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,513
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: Gyro Autobalancing

You've got the right idea, but the implementation needs some work.

First - never set motors inside if/then's like that. The motor set should be outside, over to the right of everything. You should only have 1 of any particular motor set in teleop. This helps to avoid potential race issues.

Next, your case structures should be nested inside one another. This is good coding practice, and helps to avoid extra calculations. There's no reason to check one if the other is true....

Next, you'll find this will oscillate around your setpoint. Mechanical systems have momentum, and once it starts moving it won't stop immediately. It will drive back and forth over your setpoint (probably quite wildly with a motor value of .75!).

I suggested reading some papers on PID's. That's what you need to implement here.