|
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.
|