Swerve PathPlanner Auto Not Rotating Robot Enough

@mjansen4857 This year, our team decided to use PathPlanner for our autos on a swerve drive robot. Our robot can successfully follow a path/auto without any rotations, but won’t rotate enough when asked to rotate during the path. For example, when asked to move in a straight line while rotating to end at 90 degrees, it will successfully move in a straight line, but stop at around 30 degrees.

We achieved this result by making our wheel angles negative. With normal, unaltered angles, our robot successfully turns the 90 degrees, but drives in an arc to the side.

Does anyone know what the problem here is or how to fix it?

I had a similar issue, and the solution was making sure the maximum angular acceleration and velocity matched between PathPlanner and the constraints in your code. Can you clarify what you mean by making the wheel angles negative? A +X ChassisSpeed should move the robot forward, +Y should move the robot to the left, and a positive theta should turn the robot counter-clockwise. Also, the ChassisSpeeds from PathPlanner are robot-centric not field-centric, if you feed them into a field-centric drive that could cause the arc you describe.

2 Likes

When I said “made the wheels angles negative”, I meant that we flipped the sign of the target wheel angles that were given by the module states made using ChassisSpeeds. Right before applying them to the motors, we flipped the sign, and that seemed to have a positive impact on the movement (as it resulted in perfect translational movement but just not rotational movement).

We already have a piece of code meant to make ChassisSpeeds field oriented, so that shouldn’t be a problem but we’ll double check it.

You should probably just invert the motors instead of negating angles. It just leaves less room for confusion.

The robot isn’t rotating enough because that’s just how path following with pathplanner works. The combination of translation speed and rotation speed that the path you’re trying to follow is commanding is physically impossible for the robot to do, as each module can only go so fast. So, rotation speed is slowed down to allow the translation to be followed properly. Make sure that the max module speed and drive base radius fields in your HolonomicPathFollowerConfig are correct, as this is what determines how much rotation will be slowed. Beyond that, slow down the translation constraints throughout the path using global constraints or constraint zones. If you set the above settings in the GUI as well, the path preview will give you a pretty good idea of whether the robot will be able to complete the rotation or not.

We’ll try that, thanks!