WPILib MecanumDriveKinematics angular velocity not usable

Hello, I am trying to use the wpilib MecanumDriveKinematics class to get the angular velocity on our robot, but I am getting unusable/inconsistent values. It works for getting vx and vy, so I don’t think it is a hardware issue.

In my drivetrain subsystem periodic method, I have this line

curChassisSpeeds = kinematics.toChassisSpeeds(getCurrentWheelSpeeds());

and then I have a method that returns

Math.toDegrees(curChassisSpeeds.omegaRadiansPerSecond);

Here are the graphs on SmartDashboard after rotating in place and driving a little bit to test vx and vy: (I’m pretty sure the time axes on each graph aren’t synced btw)

I can use the NavX gyro to get the actual angular velocity and it works, and you can compare the gyro and mecanum angular velocity graphs to see how the mecanum one is bad.

I am wondering if this is something wrong with my code or something wrong in the wpilib libaries

My drivetrain subsystem and full code is here

Nothing here looks totally out of the ordinary. Derivatives of measured data are noisy - often to the point where you can’t use them without a fair amount of clever filtering.

If you have a known good signal from the gyro, you should delegate to that.

Oh. Then why are vx and vy so much better?

Those are first-order differences; angular velocity is a second-order difference.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.