Hey yall, I had a quick question about how to use PathPlanner with a differential drive. I couldn’t find anything that really helped me through the documentation or anything I looked up. if anyone could send me their code of pathplanner with differential drive in java or any documentation that’s better than what is mainstream that would help me a lot.
Thank you so much!
I think what you’re looking for is the Ramsete controller example at the bottom of the documentation:
We have a simple command that we use to quickly test paths on our differential drive (typically for testing in simulation):
private Command buildAutoPath(DriveTrain drive, String pathName) {
Trajectory trajectory = PathPlanner.loadPath(pathName, new PathConstraints(
Constants.Auto.MaxSpeedMetersPerSecond, Constants.Auto.MaxAccelerationMetersPerSecondSquared));
RamseteCommand ramseteCommand = new RamseteCommand(
trajectory,
drive::getPose,
new RamseteController(Constants.Auto.RamseteB, Constants.Auto.RamseteZ),
new SimpleMotorFeedforward(
Constants.DriveTrain.StaticGainVolts,
Constants.DriveTrain.VelocityGainVolts,
Constants.DriveTrain.AccelerationGainVolts),
Constants.DriveTrain.DriveKinematics,
drive::getWheelSpeeds,
new PIDController(Constants.DriveTrain.PDriveVelocity, 0, 0),
new PIDController(Constants.DriveTrain.PDriveVelocity, 0, 0),
// RamseteCommand passes volts to the callback
drive::tankDriveVolts,
drive);
// Reset odometry to the starting pose of the trajectory.
drive.resetOdometry(trajectory.getInitialPose());
// Run path following command, then stop at the end.
return ramseteCommand.andThen(() -> drive.tankDriveVolts(0, 0));
}
Is there some documentation for the ramsete controller because this all looks crazy to me right now? Thanks!
I hear that. The gist of it is that it uses the various PID and feedforward settings to smooth out the changes over time and account for error.
The Ramsete command is like a helpful wrapper around it. You could probably glean a lot from its implementation:
Did you read through and follow the Trajectory tutorial in the WPILib documentation?
You should start with that, then try to move to PathPlanner.
ill take a look at that as well as the things posted above. Thanks!