Hello!
We’ve been having problems with our path planner generating the correct path. We’ve done tests to make sure that it’s reading the correct file (which it is). We’ve also logged the path and the robot follows that path perfectly… except that path is nothing like what we created. Does anyone have an idea on what’s going on? Thanks!
Here’s the code we have that works with the path planner library:
Configuration and path logging (in constructor of drive subsystem):
AutoBuilder.configureHolonomic(
this::getPose,
this::resetOdometry,
this::getChassisSpeeds,
this::driveWithChassisSpeedRobotRelative,
new HolonomicPathFollowerConfig(
new PIDConstants(1, 0 , 0),
new PIDConstants(1, 0, 0),
Constants.k_maxSpeedMetersPerSecond,
.475953574,
new ReplanningConfig()),
() -> {
var alliance = DriverStation.getAlliance();
if(alliance.isPresent()) {
return alliance.get() == DriverStation.Alliance.Red;
}
return false;
},
this);
PathPlannerLogging.setLogActivePathCallback((poses) -> m_field.getObject("path").setPoses(poses));
getAutonomousCommand():
public Command getAutonomousCommand() {
PathPlannerPath path = PathPlannerPath.fromPathFile("mo");
return AutoBuilder.followPath(path);
}
mo.path:
{
"version": 1.0,
"waypoints": [
{
"anchor": {
"x": 1.0,
"y": 6.7
},
"prevControl": null,
"nextControl": {
"x": 1.5,
"y": 6.7
},
"isLocked": true,
"linkedName": null
},
{
"anchor": {
"x": 2.0,
"y": 6.7
},
"prevControl": {
"x": 1.4510507342242809,
"y": 6.7
},
"nextControl": null,
"isLocked": true,
"linkedName": null
}
],
"rotationTargets": [],
"constraintZones": [],
"eventMarkers": [],
"globalConstraints": {
"maxVelocity": 1.0,
"maxAcceleration": 1.0,
"maxAngularVelocity": 540.0,
"maxAngularAcceleration": 720.0
},
"goalEndState": {
"velocity": 0,
"rotation": 0,
"rotateFast": true
},
"reversed": false,
"folder": null,
"previewStartingState": null,
"useDefaultConstraints": false
}
*the path comes out to be a long diagonal line across the field and the robot robots 180 degrees (which it isn’t supposed to do)