![]() |
Using a Gyro without Encoders
1 Attachment(s)
Hello. This is the first year we have attempted using gyros, PID, and while loops to navigate in autonomous. I think I have it right and the code does seem to work properly (I'm using a test bed as the robot is currently bagged) but I could use a second opinion to tell me if I'm doing anything wrong.
The routine is supposed to drive straight for a certain time, turn 60 degrees towards the low goal, drive straight for a certain time, and shoot the boulder. It uses a flat sequence structure with while loops in the frames that require iterative functions. 1. Resetting the gyro - Does this require some time or is it instantaneous? Where is the best place to reset this? 2. Reading gyro data - Does gyro data need to be read in each separate while loop? 3. Using wait.vi and loop iterations to keep time - I set the loop to iterate every 10 ms and to terminate when it reaches 500 iterations. I assume this will be 5 seconds. Is there any reason this would not be 5 seconds? Is there a better way to do this? Any help is appreciated! |
Re: Using a Gyro without Encoders
While I don't have answers to all of your questions I would like to point out that the gyro reports angles in the range of 0-360 degrees. You'll probably want to normalize any readings greater than 180 degrees to their negative equivalents in order to get the PID vi in drive straight to work properly. Simply compare the reported gyro angle to 180 degrees. If greater than 180 degrees then subtract 360 and voila you get reported angles from -179.999 to +180. That way a reported angle of 350 degrees gets converted to -10 degrees which I believe the PID vi can make sense of.
Hope this helps. |
Re: Using a Gyro without Encoders
1 Attachment(s)
Quote:
|
Re: Using a Gyro without Encoders
Quote:
I don't think I've seen the gyro vi report angles less than zero. |
Re: Using a Gyro without Encoders
The angles published to the dashboard from the Gyro Get Angle vi did return negative values and the motor did seem to compensate correctly for these. Is it possible that this -180 to +180 feature is built into the gyro Get Angle vi?
|
Re: Using a Gyro without Encoders
Quote:
Much humbled. Sorry for the mis-information. |
Re: Using a Gyro without Encoders
1 Attachment(s)
Quote:
Quote:
The post and thread I linked above shows how to turn any angle into +/-180 degrees. If you compute the angle error ( = target-gyro ) and feed that error into the computation, it will give you the setpoint you should use to go the shortest angle to get to your target (or just see below). Quote:
|
Re: Using a Gyro without Encoders
Quote:
|
Re: Using a Gyro without Encoders
Now that we know how Labview uses gyros... does anyone have any comments on my original questions? :)
|
Re: Using a Gyro without Encoders
Quote:
1. You could place the reset in the first frame of the sequence but I think it's OK where you have it. Not sure though if the reset is instantaneous but from what I've seen it only takes some fraction of a second. 2. Yes you need to read the gyro in each while loop. When a while loop is active the while loops in the other frames in the sequence structure are not executing. 3. This has been a common technique shown in examples from previous years. I think your assumption of a 5 second loop time is correct. I see no reason to change it. Sorry if we hijacked your thread. Hope this helps. |
| All times are GMT -5. The time now is 03:48. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi