Pathing with Path Planner with Swerve Drive causes robot to follow where robot is pointed

Our team has been trying to get Swerve Drive to work with Path Planner. When we draw a straight path but change the holonomic rotation at the end point the robot spins in a spiral, it looks like the robot’s holonomic rotation is the direction the robot will drive even if that isn’t the correct way. Our team is stumped on what is causing the issue, we could get some results with using Path Weaver while also setting the desiredRotation Supplier to 0 and it would follow the path fine, always keep one side of the robot in the front, never rotating. Our code is at Github. Any help would be greatly appreciated!

1 Like

Did u enable holonomic drive train in path planner?

You need to update your odometry in your swerve subsystem’s periodic method. If you never update your odometry, the rotation and position of the robot will always be reported as 0.

Thank you so much! We had that in a previous project but when I was updating the code because of minor changes, I must have deleted that. I will be trying that tonight! Many thanks from me.

So unfortunatly it didn’t complete solve the issue, the robot looks like it travels forward based on where the front is. It drives in a circle if I give it a long path two point path with the holonomic rotation being 180 degrees different than the start point.

I’m not totally sure if this is the case, but you are negating the value of the navx getRotation2d method here. I believe this method already negates the yaw for you. You should only need to negate it if you are creating the Rotation2d yourself using the getAngle method.

The source of the getRotation2d method in the WPILib gyro interface negates the getAngle method, which returns cw+.

1 Like

Thanks for all the help! The angle was the issue. Thanks so much!

1 Like