Using gyro to compensate for swerve rotation

I saw someone suggesting using the gyro to compensate for the robot rotating while driving straight. How can we do that? Will calculating the delta between desired angular velocity and measured angular velocity and inserting the difference to the chassis speeds object work?

Have a look at our swervedrive.java file. We have our drive method hold the angle of the robot when a 0 rotational speed is given.

Maybe 1684’s white paper can help you with it. Team 1684 - ChimiSwerve Code Whitepaper - CD-Media: Papers - Chief Delphi
In the 2.3d chapter, the have described it in detail.

But you can also replace it with WPI’s PIDController. Just in the calcyawstraight(). Just like @vargoose84 has done in their code.

If you have any other questions ,feel free to ask in this post!

1 Like