Possible bugs in Rotation2d and Rotation3d - java

Zero.

Velocity is the displacement divided by time. If I walk from home to school and from school to home in one hour, my average velocity in this hour is zero because my displacement is zero.

If what you want is the average speed, don’t use Rotation2d in the first place. You are treating the rotation as a continuous scalar like distance.

This analogy would make sense if, at some point in the 1 second, the robot started rotating in the opposite direction. I think we can agree however that Ryan’s example has a positive angular velocity, to go from 0 to 2pi, and at no point does the angular velocity become negative.

2 Likes

Technically, it really depends on how you define

In this case, Rotation2d represents the facing of a robot or the direction of a point in the trajectory. To that extent, 0 degrees and 360 degrees is the same thing. So, there is no angular displacement and, therefore, zero average angular velocity.

My point is,

currentRot.minus(previousRot).getRadians() /  dt

is the universal solution to finding the angular velocity.

It works regardless of how you define angular velocity or whether the input angles are wrapped.

The only case where it does not work is when your robot travels more than 180 degrees between robot periods, as @Ryan_Blue has pointed out. But what robot can rotate 25 revolutions in a second, achieving an angular velocity of 9000 degrees per second?