PathPlanner Not Generating Correct Path

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)

1 Like

The path is being flipped to the red alliance, so the path is on the other side of the field. Replanning is trying to get the robot over there. Your robot odometry is likely on the blue side of the field.

If you’re looking for this to be an auto mode, it’s much easier to use the auto files. Those will have a starting pose and automatically reset odometry for you.

Alright, that makes a lot of sense. So if I want PathPlanner to reset odometry for me I should use auto mode (even if I just want to run one path with it)? I’m assuming this will reset the robot pose to the red or blue side depending on what drive station says?

Depends on if you tell it to flip the path or not in the method supplied to auto builder. If you copied from the example, then yes.

You either need to use auto modes to reset the pose or just start in the general right spot odometry wise, if odom has already been previously reset.

Alright, thanks!

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