|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Gyro for driving straight
Can somebody please provide me with a basic example of how to use a gyro with tank drive to drive straight for a defined encoder distance during autonomous.
|
|
#2
|
||||
|
||||
|
Re: Gyro for driving straight
Quote:
The basic approach it to add the gyro provided angle, time some gain factor, to one side of the drive and subtract it from the other. Code:
Psuedo code: L = L+(Gyro*gain1) R = R-(Gyro*gain1) |
|
#3
|
||||
|
||||
|
Re: Gyro for driving straight
No disrespect but this is the NI LabView forum so I would assume the OP would like a LabView example.
Last edited by kylelanman : 28-03-2014 at 20:11. Reason: typo |
|
#4
|
|||||
|
|||||
|
Re: Gyro for driving straight
It's a lot easier to do with Arcade Drive.
Reset the encoder and the gyro before you start moving. Use the gyro angle (multiplied by an empirically determined gain value) as the X axis "turn" input. Put the Gyro Get and the Arcade Drive blocks in a while loop that terminates when the encoder reaches the desired value. |
|
#5
|
||||
|
||||
|
We have a gyro on our robot and we mainly use it for auto. We had it do what you wanted, granted it is a mecanum drive but we found it actually slowed us down a lot. I'm not our programmer so i can't help with the program, but i would think about what you really want it for so you don't waste your time. Just my advice. They are wonderful for the right situation. Ours wasn't, but yours might be.
|
|
#6
|
||||
|
||||
|
Re: Gyro for driving straight
Quote:
I have seen a LOT of posts in incorrect forums and did not want to assume, thus the request. |
|
#7
|
||||
|
||||
|
Re: Gyro for driving straight
Try searching for 1986 Team Titanium's 2013 Code here on CD. Their 2013 autonomous is a great example of exactly what you're wanting here (and it worked every time).
The "gain" other posters are talking about is calculated with PID and it takes some fine tuning. Tank drive would take a lot more math and headache to get right and you wouldn't have as much control over the turn. Like Alan said, I'd stick with Arcade for this Autonomous if I were you. EDIT: this is one example of what you're looking for ![]() Last edited by Invictus3593 : 21-04-2014 at 17:33. |
|
#8
|
|||
|
|||
|
Re: Gyro for driving straight
Hello,
If I simply wanted to turn right 60 degrees in autonomous, could I put the arcade drive vi in a while loop and tell it to turn right until the Get Angle vi >= 60? The idea is to drive for a time, turn 60 degrees to the right, drive some more, and shoot. I wanted to use a flat sequence structure (film strip) with a while loop in the frame that does the 60 degree turn. Would this work? Thanks! PS: We don't have encoders. |
|
#9
|
|||
|
|||
|
Re: Gyro for driving straight
Quote:
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|