• Welcome to Redshift Project Depot.
 

Swerve drive equations

Started by Louis L, January 09, 2017, 11:46:41 PM

Previous topic - Next topic

Louis L

Unlike mecanum, there is no built-in support for swerve drive in WPIlib or LabVIEW. Here's where you can find some information:
https://www.chiefdelphi.com/media/papers/2426

Brayden L

Specifically the file titled first and second files in the link, titled Calculate Swerve Wheel Speeds and Steering Angles and Derivation - Inverse Kinematics for Swerve (the first one is better for integrating straight into code, second one shows how it works)

Vanshika C

There's conflicting information on these documents. The "Derivation - Inverse Kinematics for Swerve" pdf says that the calculation of A, B, C, and D is:


A = STR - RCW * L/2
B = STR + RCW * L/2
C = STR - RCW * W/2
D = STR + RCW * W/2


, but the "Calculate Swerve Wheel Speeds and Steering Angles" pdf says it's:

A = STR - RCW * L/R
B = STR + RCW * L/R
C = STR - RCW * W/R
D = STR + RCW * W/R


My own calculations and math agree with the 1st pdf. I can upload a picture of my work if you'd like.
Anyone testing the swerve calculator on the spreadsheet will have to change the formulas for A, B, C, and D as they use the 2nd pdf's formulas.

Maybe someone should post on ChiefDelphi to ask about this conflict?

Vanshika C

#3
Also, here's my code for the swerve drive equations in C++. You can compare the results with those of the spreadsheet, just be sure to change the formulas for A, B, C, and D first. Also, this is just test code so the documentation isn't great :/

Louis L

Interesting. I haven't had time to go over those equations yet. Will try and get to them tomorrow.

Louis L

Status update for 1/17/17

SW teams are working to get a handle on controlling the steering motors. Java team is taking the lead here. The current problem is trying to integrate PID with the steering motor. While the act of doing this makes sense, the actual way of doing it under WPI's library seems a little kludgy. Unlike a traditional moving mechanism where a motor is asked to cause motion from the current point to a new set-point, the drivetrain is doing this with a potentially constantly  changing set-point. Maybe it doesn't really matter? So far it's not working. More debug to come.