![]() |
Gyro Turning
So i know that gyros can help your robot drive straight in autonomous, but can they also turn your robot? Say im going forward for 3 seconds and then i want to turn 90 degrees to the left. Can the gyro help me do this and then continue driving straight?
|
Re: Gyro Turning
Yes, it is definitely possible. You would probably want to use PID. The basic logic goes something like this.
The input of the PID is the gyro angle. The setpoint of the PID is 90 degrees. The output of the PID is 1 side of your drivetrain, and then the other side of your drivetrain should run at the exact opposite of the normal output. Hope this helps. |
Re: Gyro Turning
So Kp would be the value of the angle? Say i were to want it to turn 90 degrees, P if PID would be 90?
|
Re: Gyro Turning
Quote:
Code:
/** |
Re: Gyro Turning
No, Kp is the proportional gain term. It's a value which is multiplied by the measured error. Where "error" is your desired position (input into the PID controller) minus actual measured position.
I would suggest reading up on PID controllers, and learn at least at a high level how they operate before attempting to use one on your robot. Some helpful links: PID without a PHD (pdf) a good overview of how different controllers work PID Tuning This one will help you choose your gains. That said, you can turn x number of degrees using the gyro without a PID controller. A simple implementation is provided below. If you have never used a PID controller before, it may be easier to implement a simple algorithm like what is below, then itterate on the design to improve the performance problems you identify. Sudocode (this needs to be run in a loop in a simple robot project, or have supporting state variables in an itterative or command based robot project (to flag when you're finished) Code:
//Positive angle is roatation clockwise |
| All times are GMT -5. The time now is 22:35. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi