Swerve drive skew while driving and spinning

Hi! My team built a swerve drive for the first time this year, and we’re encountering an issue that we haven’t been able to resolve. When driving forward and spinning at the same time, the robot skews significantly in the direction that it is rotating.

As far as I can tell, it’s the same problem that’s described in this post. We have tried the solutions suggested in that thread, even copying directly from other teams that implemented fixes for the issue, roughly:

private static ChassisSpeeds correctForDynamics(ChassisSpeeds originalSpeeds) {
    final double dt = 0.02;
    Pose2d futureRobotPose =
        new Pose2d(
            originalSpeeds.vxMetersPerSecond * dt,
            originalSpeeds.vyMetersPerSecond * dt,
            Rotation2d.fromRadians(originalSpeeds.omegaRadiansPerSecond * dt));
    Twist2d twistForPose = log(futureRobotPose);
    ChassisSpeeds updatedSpeeds =
        new ChassisSpeeds(
            twistForPose.dx / dt,
            twistForPose.dy / dt,
            twistForPose.dtheta / dt);
    return updatedSpeeds;
}

As well as the implementation that will apparently be in WPILib 2024.

However we still haven’t been able to get rid of the problem. Are there any other things that we could try?

Are there any teams that have managed to solve this issue completely? Or is this just something that is inherent to swerve?

Thanks!

Even with the fixes highlighted, my understanding is that if your robot has a center of mass that is not at the axis of rotation, then there will be some unavoidable skew when rotating.

Furthermore, I believe the whitepaper outlines that even with second-order kinematics, there will still be some skew since the system is not ideal.

1 Like

Perhaps try to tighten your module steering control? If it’s too slow to respond you can drift in unwanted directions while you move to the target angle.

2 Likes

We’re having the same issue. I’ve tried implementing the pose exponential method but it doesn’t seem to do anything different. I do have some questions though—
Should the “futureRobotPose” be created using field-relative or robot-relative speeds?
The example given by @Jared_Russell uses what appears to be a static call of “Pose2d.log()”, but the WPILib Pose2d class does not support this— what should the starting pose be?

It’s a built in method now FYI ChassisSpeeds (WPILib API 2024.2.1)

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