Sample Gyro Code for Autonomous - LabVIEW

Hey,
We started playing with our Autonomous code today and we can’t go straight (although its not an issue in Teleop) so we’d like to make use of a gyro but we don’t know how.
Can someone share some LabVIEW screenshots of how to make use of the gyro to drive straight in autonomous?
Thanks so much!

The primary thing you want to do is to read the gyro in a loop to identify any rotations and steer the other direction to negate any drag or other forces causing your robot to turn.

You can either use the gyro in a relative mode, where zero is the direction you want to travel, or you can use an absolute coordinate system that is field centric. Either way, compare the gyro value to the desired value (subtracting actual from desired is the typical way to do this). This is your error term.

To correct the error, you want to influence your steering. An easy way to think about this is to use the arcade version of Robot Drive. You can keep the Y value constant and send the error term (or a multiple of it) to the X value.

This multiple, or proportion, is used to tune the robot for a given range of speed.

So the code ultimately look like.

error= measured - actual
X= error * proportion
drive with X and Y joystick values

The proportion can be negative if your gyro increases one way and your joystick in the other. The proportion varies depending on the units of your gyro and how aggressive you want it to correct for the error.

When tuning, start with a slow Y speed and shoot for a steering value to X of maybe 0.2. Put the robot on blocks or even better on a furniture dolly. Run the code and hopefully all wheels go forward at the same rate. Rotate the robot on the dolly and you will either see the wheels steer into or against the rotation. You may want to put some marks on the wheels to see this better.

Once it seems logical, and safe, put the robot on the ground and repeat the test. Increasing the magnitude of the proportion will steer more aggressively, lower will steer more gently and avoid oscillation/oversteering.

Greg McKaskle