wpilibsuite / allwpilib

Official Repository of WPILibJ and WPILibC
https://wpilib.org/
Other
1.06k stars 614 forks source link

Add Mecanum and Swerve trajectory tracking examples #1955

Closed calcmogul closed 4 years ago

calcmogul commented 4 years ago

Mecanum is holonomic, so controller options exist that are better than Ramsete. The control loops can be decoupled into separate ones for x, y, and theta. If one lets the controllers produce desired velocities and angular rates, one can stick them into a ChassisSpeeds instance and use MecanumDriveKinematics to convert them to wheel speeds (this assumes closed-loop velocity control on each wheel as with Ramsete).

Regarding trajectory generation, heading is decoupled from chassis speed, so the user can use just the x,y points from wpilib traj gen and make the heading whatever they want. Linearly interpolating between the heading at waypoints is a good option. A trapezoid profile on heading is another to ensure continuous heading rate.

Swerve is also holonomic, so it can use the exact same code with the name "Mecanum" replaced with "Swerve".

calcmogul commented 4 years ago

Closed by #2052.