We’re planning on making a Robot-Oriented Drive system this year (game willing). In this process it became obvious that programming is a bit tricky, so we made a spreadsheet that takes X,Y,and Rotation values and gives each of the 4 wheel orientations and speeds.

The spreadsheet was made such that you should be able to follow step by step through the calculations and translate it to programming.

Enjoy, and pass along any suggestions or questions.

-Matt

Swerve Sim.xls (29 KB)

Swerve Sim.xls (29 KB)

Very cool! Saved to my computer to peruse later.

There is a very detailed set of papers and a simulation spreadsheet available here as well…

More is more.

Ether’s Swerve Stuff

The method used in the spreadsheet seems slightly incorrect and will give some wrong numbers. One of these cases is when Joystick Y = 1 and Rotation = -1. The spreadsheet will give the following results.

``````
Angle 	Power
Wheel 1 270.00	0.45
Wheel 2	333.44	1.00
Wheel 3	26.57	1.00
Wheel 4	90.00	0.45
``````

The robot will look as follows (where the length of the arrow roughly equals the power).

In the image above the robot might seem to move correctly but the wheels will scrape across the ground and will lose a lot of power. The robot should look like the following.

This is caused by a slightly incorrect algorithm. For a correct algorithm I would heavily suggest that you look at Ether’s swerve stuff as posted above, specifically, the first attachment.

Also, the way you deal with scaling the power values is incorrect. The two following cases give the same results.
Joystick Y = 1 and Rotation = -1
Joystick Y = 0.1 and Rotation = -0.1
To solve this problem you need to take the power values and multiply by the maximum magnitude of the joysticks.

Mr. Giggums

Thanks for taking a look. I went back to my sheet and found 3 errors. First I had switch wheels 3 & 4 on the layout diagram. Second I had weighted both the X and Y components of rotation at 1.0 which gives a total resultant of 1.41 which makes the vector from rotation too heavily factored into the overall resultant. I corrected that and the weighting to .707.

I also found the problem with scaling. Turns out that I was scaling the numbers so max motor value was 1.0. I changed it so it only scales if a motor value is >1 now.

Thanks for checking it for me. It seems to correlate pretty well to Ethers numbers now.

I’ll attach a new version with corrections for anyone whose interested.

Swerve Sim3.xls (103 KB)

Swerve Sim3.xls (103 KB)