Gyro and Tank Drive

Hey all, I am currently trying to get the gyro to work with our robot and our robot currently drives in tank drive and we’d like to keep it that way, but still be able to use the gyro. I am unsure how to go about programming the gyro with tank drive as I can only find resources about using the gyro with only one joystick controlling the forward and back movements of the robot.

Any help would be great, thank you in advance :slight_smile:

What are you hoping to improve about your drive control by using a gyro?

We are using tank drive with two joysticks, one controls forward/back and the other controls left/right

We are using an ADXRS450 to keep the robot going straight while we drive. We use a P-controller that “takes over” the role of the turning joystick when driving straight.

Our code is on our repository here:

Is this what you are looking for?

Yes exactly. I am wanting to use it basically for keeping the robot on a straight drive. Thanks :slight_smile:

Your threshold for when to use the straight-driving code seems very small at only 1% of the joystick range during normal driving. When I have made similar code in the past I recall making the threshold much higher, like between 5% and 15%.