Redshift Project Depot

FRC 2017 (Steamworks) => Robot Software => Topic started by: Louis L on January 09, 2017, 11:46:41 PM

Title: Swerve drive equations
Post by: Louis L on January 09, 2017, 11:46:41 PM
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
Title: Re: Swerve drive equations
Post by: Brayden L on January 13, 2017, 06:48:31 PM
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)
Title: Re: Swerve drive equations
Post by: Vanshika C on January 14, 2017, 05:14:48 PM
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?
Title: Re: Swerve drive equations
Post by: Vanshika C on January 14, 2017, 05:36:49 PM
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 :/
Title: Re: Swerve drive equations
Post by: Louis L on January 15, 2017, 09:26:07 PM
Interesting. I haven't had time to go over those equations yet. Will try and get to them tomorrow.
Title: Re: Swerve drive equations
Post by: Louis L on January 18, 2017, 10:33:34 AM
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.