Class PathPlannerUtil

java.lang.Object
com.stuypulse.robot.util.auton.PathPlannerUtil

public final class PathPlannerUtil extends Object

PathPlanner Utility

Loads PathPlanner path (.path) files from the deploy directory and builds named autonomous routines from those paths.

Usage

For example, inside Robot.configureAutons(), you can create a PathPlannerUtil.PathPlannerConfig, pass in the auton name, factory method, and path names, then register it with AutonOpMode via PathPlannerUtil.PathPlannerConfig.register().

AutonFactory factory = new AutonFactory(swerve);

PathPlannerConfig scoreAutonConfig = new PathPlannerConfig(
                "Score",
                factory::score,
                "Score Path");

scoreAutonConfig.register();

The factory method receives the loaded paths in the order listed and returns a PathPlannerAuton. Use PathPlannerUtil.PathPlannerConfig.register() for a regular option, or PathPlannerUtil.PathPlannerConfig.registerDefault() for the chooser's default option. A config can also register directly with a LoggedNetworkChooser when a custom chooser is used. The methods without a chooser register the routine with AutonOpMode.

Path names are checked when the configuration is created. Missing paths are reported to the Driver Station with a suggested closest match when one is available.

  • Constructor Details

  • Method Details

    • loadPaths

      public static com.pathplanner.lib.path.PathPlannerPath[] loadPaths(String... names)
      Loads multiple PathPlanner paths in the order given. Each name is passed to load(String).

      If a path cannot be loaded or found, an error is reported to the Driver Station, and null is returned in the corresponding position.

      Parameters:
      names - PathPlanner path names to load
      Returns:
      The corresponding paths where entries that fail to load are null
    • load

      public static com.pathplanner.lib.path.PathPlannerPath load(String name)
      Loads a PathPlanner path by name.

      If the path cannot be loaded or found, an error is reported to the Driver Station, and null is returned.

      Parameters:
      name - PathPlanner path name
      Returns:
      The loaded path, or null if not found