YAGSL-Example icon indicating copy to clipboard operation
YAGSL-Example copied to clipboard

CalculateMaxAngularVelocity now uses the physical radius of the modules

Open yapplejack opened this issue 7 months ago • 6 comments

When calculating the maxAngularVelocity of the robot a Rotation2d is used. A rotation2d uses a unit circle, which will does not accurately represent the size of the robot.

image

image

image

image

For example, my robot has modules at (+/- 0.28575m, +/- 0.28575m) and a max velocity of 4.8 m/s (max standard gearing of a MaxSwerve). When using rotation2d we get 6.1 m/s for the max angular velocity:

image

Using inches instead of meters for the module location yields the same result of ~6.1 rad/s when the velocity is still in m/s (0.28575 -> 11.25 in):

image

I replaced this with $w = \frac{v}{r}$ which yields $\frac{4.8}{0.404112} = 11.87789 rad/s$. This number can be mentally checked by thinking about the distance traveled as the circumference of the circle that swerves make: $C = 2\pi r \rightarrow C = 2.53782336 -> \frac{4.8}{2.5378} = 1.89$ revolutions per second.

Apologies if I have a misunderstanding for the usage of the unit circle if that was intentional. With this change you may want to update your examples and the tuning webpage to use meters and specify that meters are desired. I would also be happy to make those changes if my push is approved.

image

image

image

yapplejack avatar Jul 24 '24 17:07 yapplejack