Swerve Pathplanner Does Not Rotate Robot

Our team is trying out Pathplanner for the first time with swerve. When we run the trajectories in auto, the translational motion seems completely fine, but the robot does not rotate enough, and does not rotate while moving, only at the end. When we looked at the telemetry data, we found that the robot is being commanded to rotate only very briefly. In the preview, the bot clearly rotates 180 degrees.

Our code is based off the MAXSwerve example code, and we followed the Pathplanner docs to add the trajectory following stuff.
When we try to follow trajectories with the guide on WPILib, the bot rotates completely fine.
Our constraints in Pathplanner and code are:
Velocity: 1m/s
Acceleration: 3m/s^2
Ang Velocity: 540deg/s
Ang Acceleration: 720deg/s^2

Our code

My first guess is your slew rates are limiting your rotation. Also 540 deg/s is a lot

Remember that PP is time-based. That means it will stop trajectory when the timer expires vs when you reach the final state. So if you overestimate capabilities of your robot, you will not complete the trajectory.

Also - which branch of your code and which command runs auto in question?

I looked at the code in the link and for some reason could not see the auto you referenced.

Even when we make the path take a long time (like setting max velocity = 0.5 m/s, making the path take 2.46s), it still cannot do the 180 degree rotation, and only starts rotating towards the end.

Our auto path file is located on the Pathplannerlib branch at src/main/deploy/pathplanner/autos/Copy of test auto.auto.

The place that selects the auto command is in the initialization of our RobotContainer. We just followed the last section in “Build an Auto” in the Pathplanner docs

Thank you, I will definitely try this out. Would this also explain why the robot only starts turning towards the end of the path?

Potentially

1 Like

We had the same problem and what worked for us was putting the max module speed at 5m/s and putting our linear speed at 1m/s
I think that as long as the the module speed is high enough it would work put that’s the values that worked for us
Those options should be somewhere in pathplanner config but I’m part of our programming teams so I can’t help more than this

Thank you, I will try this. Do you remember what angular speeds you put?

I believe the max angular acceleration and velocity we set were respectively 540°/s^2 and 720°/s. I think it should work as long as your max module speed in your code is higher than your max velocity in your path?

This number does not represent the max speed you want to follow the path at, it represents the max speed of the module. You’re essentially telling the path following command that each module can only go at a maximum of 0.5 m/s. Any translational speed above that will mean there is 0 speed left over to do any rotation. Set this number to the actual max speed of your modules.

Thank you so much!