Robot not making full 180 in pathplanner

Our team is trying to use pathplanner for our autos. We have made an auto that spins the robot all the way around. The robot turns 90 degrees and then back to 0.

IMG_7921

have you had a chance to tune your kPX kPY and kPtheta controllers in your constants? The way your robot is moving compared to the drawn path also looks like you may want to double check if your headings for all waypoints make sense.

Can you post a gif of that path playing in pathplanner?

I tried tuning my x and y controllers but regardless of number, it didn’t really seem to do much. I also “tuned” the theta controller to turn to exactly 90, but when going to 360 it won’t work.

I’m not that familiar with path planner but it appears you actually want to turn 180 degrees not 360 degrees. I.e. the last bot position needs to be flipped 180 degrees. This would explain why it initially turns 90 degrees as you appear tell it to be 90 degrees turned by about 2/3rds of the way through your path.

You are right. I do want to move 180 degrees. In path planner, the white dot signifies the front of the robot if I recall correctly. It it facing forward in the beginning but backwards in the end. The path looks to be right and works how I would expect on the overview.

Ive done some testing.
image
In this test path, the robot should drive forward and turn to face 180 degrees. In real life, the robot starts driving backwards and goes to 90 degrees.

We had the same issue. For some reason when the gyro is not set to the angle by pathplanner’s transform state by alliance function it does weird things. This happened for us even when we were using the swerve odometry which tracks delta angle. How it changes anything I don’t know but the yaw must be set to the one from path planner’s function.

I should add the the odometry should be set to the initial pose with the rotation being the holonomic rotation, not the one inside the the initial pose. You will need to reset your gyro afterwards. I did this by tracking angle deltas and resetting them when the command ended.

What exactly was your fix?

PathPlannerState allianceState = PathPlannerTrajectory.transformStateForAlliance(path.getInitialState, DriverStation.getAlliance());

swerve.poseEstimator.resetPosition(swerve.gyro.getRotation2d(), swerve.getModulePositions(), new Pose2d(allianceState.poseMeters.getTranslation(), allianceState.holonomicRotation));

Then to get rid of the weird stuff that path planner does to the gyro we track the gyro delta and reset it properly based on alliance at the end of auton. This is very important because path planner does weird things when flipping alliance states.

1 Like

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