Swerve Drive Kinematics

We went to implement swerve kinematics/odometry and found that they aren’t included in the robotpy version of the wpilib.kinematics package. As they are in the C++ library, is this something that is currently planned on being added to robotpy, or should we start developing alternative methods of auto control/manipulating the mecanum kinematics?

Glad you asked! When originally implemented, I didn’t have template support, so I didn’t include them. However, I’ve since added template support, so we can add them – I just neglected to do so.

How many wheels do you need?

Also, I’ve opened a github issue to track this @ https://github.com/robotpy/robotpy-wpilib/issues/667

Thanks! We use 4 modules

If you don’t want to wait, I did port the swerve kinematics to pure-Python during the off-season, which you could copy-paste into your project:

You’ll need to change the imports and potentially some method names. It also depends on numpy if you don’t already have it installed. It’ll will work for an arbitrary number of modules.

That will let us start testing tomorrow. Thanks for sharing

wpilib 2020.3.2.1 will be uploaded in a few minutes, and contains swerve module kinematics support. Let me know how it goes!