![]() |
gyro c++ Programing
can anyone direct me on how to properly program the robot to drive in autonomous mode with the gyro?
|
Re: gyro c++ Programing
That is a very broad question. Can you narrow it down to more specifics what you want to do in autonomous? Gyro is normally used to determine your heading. If you want to tell the robot to turn a certain angle during autonomous, you can certainly use it to achieve what you want. If that's what you want to do, you can either program the robot to turn at a constant speed while monitoring the reading of the gyro until it reaches the target then you stop, or you can use PID control to adjust the speed while you turn (i.e. slow down when you are close to your target).
|
Re: gyro c++ Programing
in the gyro example they use this
Code:
gyro.Reset(); |
Re: gyro c++ Programing
Would this work
Code:
//what tommy wants |
Re: gyro c++ Programing
A simple way, not necessarily the best way, is to do the following:
Code:
float targetAngle = gyro.GetAngle() + 45.0; |
Re: gyro c++ Programing
That looks like it will work better than mine
|
Re: gyro c++ Programing
Well, it is not the best way especially on the Wait(3.0). The cRIO has a watchdog timer. You need to feed it periodically or your motors will be cut out. Waiting for 3 seconds will definitely starve your dog. So instead of a plain Wait(3.0) statement, you may want to read the timer in a loop. I beleive the WPI library this year will feed your watchdog for you when you call any of the Drive methods. If not add a feed watchdog statement in each of the loops. So something like this:
Code:
float targetAngle = gyro.GetAngle() + 45.0; |
Re: gyro c++ Programing
Placing any sort of loop in your overridden functions (such as AutonomousPeriodic()) is discouraged.
Code off the top of my head: Code:
// ... |
Re: gyro c++ Programing
Basicxman,
That's why I said it's not the best way. What you are doing is essentially a state machine. That's the preferred way to do it. In general, one should be able to code the entire competition without using a single wait loop. Whenever you need to wait, you return. And the next time you get called, you check the condition again. If it's still not ready, you return again. When it is finally ready, you move on to the next state. Using a state machine not only allows you to eliminate wait loops, it also allow you to do several things concurrently. For example, moving your claw while tracking the line simultaneously. |
Re: gyro c++ Programing
Quote:
|
| All times are GMT -5. The time now is 17:43. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi