PathPlanner Documentation

repository·main·Indexed 19 days ago

https://github.com/mjansen4857/pathplanner

A motion profile generator for FRC robots featuring Bézier-curve-based paths, autonomous routine management, and real-time telemetry. Includes PathPlannerLib for robot code integration with support for Java, C++, and Python, as well as a Flutter-based application for path creation. Key features include FollowPathCommand for trajectory execution, PathfindingCommand for navigating to poses or paths, and a flexible CommandGroup system for sequencing autonomous behaviors.

Tokens
35.5K
Snippets
90
Records
146
Agent score
66%

What's inside PathPlanner

  1. Overview of PathPlanner features

    main

    PathPlanner is a motion profile generator for FRC robots (created by team 3015) that provides the following capabilities:

    • Path Generation: Uses Bézier curves for fine-tuned path shaping.
    • Holonomic Support: Decouples robot rotation from direction of travel.
    • Real-time Feedback: Includes real-time path preview and real-time path following telemetry.
    • Event Markers: Allows placing markers along a path to trigger specific code during execution.
    • Modular Routines: Build autonomous routines by composing multiple paths.
    • PathPlannerLib Integration:
      • Robot-side vendor library for path generation and custom controllers.
      • Full autonomous command generation via the PathPlannerLib auto builder.
      • Automatic pathfinding using AD*.
    • Workflow Efficiency: Automatic file management, hot reload (update paths/autos on the robot without redeploying), and automatic saving.
  2. Use the Project Browser to manage paths and autos

    main

    The Project Browser is the main interface for managing and opening path and auto files. The interface is split into two sections: paths on the left and autos on the right. You can adjust the relative size of these sections by dragging the handle between them.

    Key features include:

    • Sorting: Both paths and autos have independent sorting options.
    • UI Modes: Both sections can be toggled between default and compact UI modes.
    • Creation: Use the icon buttons in the top right of each section to create new folders or new paths/autos.
  3. Define autonomous routines using Autos

    main

    In PathPlanner, Autos are used to define complete autonomous routines. An auto is structured as a sequential command group containing various types of commands:

    • Path following commands: Allows you to select and reuse any path defined in the project.
    • Named commands: Corresponds to the names used in path event markers.
    • Wait commands: Pauses the routine.
    • Nested command groups: Allows for complex, hierarchical routine structures.

    Integration Options:

    1. Auto Builder (Recommended): Load the auto as a full autonomous command in your robot code using PathPlannerLib's auto builder functionality.
    2. Path Groups: If not using the auto builder, you can use the auto files in PathPlannerLib to retrieve a path group or a list of paths contained within the auto (similar to the legacy path group system).
  4. Understand Path and Waypoint concepts

    main

    In PathPlanner, a Path represents a single continuous motion segment (e.g., driving from a start point to a game piece). Multiple paths can be chained together to form an autonomous routine.

    Waypoints define the shape of the spline the robot follows within a path. Each waypoint consists of:

    • Anchor Points: The exact $(X, Y)$ position on the field (in meters) that the spline passes through.
    • Control Points: Points used to define the heading (tangent) and fine-tune the spline shape via their distance from the anchor point.

    Key Waypoint Operations:

    • Add: Double-click on the field in the path preview to add a waypoint to the end of the path.
    • Edit: Click and drag waypoints in the path preview or use the Waypoints Tree.
    • Link: Use the Link Waypoint Button to give waypoints a shared name. Updating one linked waypoint updates all others with that name across all paths.
  5. Configure Event Markers and Triggers

    main

    Event markers trigger commands at specific points along a path.

    Non-Zoned Events

    • The command is triggered when the robot reaches the marker.
    • The trigger goes true for one loop.
    • The command is not canceled unless it is still running when the path ends.

    Zoned Events

    By checking the Zoned Event Checkbox, you create a region with a start and end position.

    • Start Position Slider: The waypoint relative position where the event begins.
    • End Position Slider: The waypoint relative position where the event ends.
    • The associated command is scheduled/canceled based on the robot's position within this zone.

    Note: When a path ends, all commands triggered via event markers are commanded to end. To run a command at the end of a path, place it at the start of the next path or use Autos.

  6. Configure Global Constraints

    main

    Global Constraints define the kinematic limits of the robot for the entire path, used whenever a specific Constraint Zone is not active. These can be edited via the Global Constraints Tree.

    Available Parameters:

    • Max Velocity: Maximum velocity in meters/sec.
    • Max Acceleration: Maximum acceleration in meters/sec².
    • Max Angular Velocity: Maximum angular velocity in degrees/sec.
    • Max Angular Acceleration: Maximum angular acceleration in degrees/sec².
    • Nominal Voltage: The expected battery voltage (volts). This helps limit speeds during voltage sags (e.g., when using a shooter).
    • Use Default Constraints: Toggles connection to the default constraints in the settings menu.
    • Unlimited: If enabled, the robot moves as fast as torque allows, ignoring velocity/acceleration limits.
  7. How to override controller feedback in PPHolonomicDriveController

    main

    In certain scenarios, such as targeting a specific game piece, you may need to override the default controller feedback during path following. You can do this by providing a function to the PPHolonomicDriveController class that supplies custom feedback for X position, Y position, or rotation.

    Important Considerations:

    • These are static methods, meaning an override applies to all path following commands currently in use.
    • The provided function is called every loop. Ensure your logic is efficient.
    • You must manually clear the feedback override functions when you no longer want to use custom feedback to avoid unintended behavior.
  8. Use Point Towards Zones

    main

    Point Towards Zones force the robot to aim at a specific field coordinate while traveling through a designated segment of the path.

    Configuration:

    • Field Position X/Y: The target coordinates on the field in meters.
    • Rotation Offset: An additional rotation (degrees) added to the target angle (e.g., to point away from a target).
    • Start Position Slider: Relative waypoint position where the zone begins.
    • End Position Slider: Relative waypoint position where the zone ends.
  9. Use Event Triggers to bind commands to event markers

    main

    Event Triggers allow you to bind commands to specific event markers defined in PathPlanner. This provides more flexibility than standard named commands, enabling you to:

    • Bind commands to the start or end of a zoned event.
    • Run a command only while the robot is within a specific zoned event.
    • Combine multiple event triggers to handle overlapping zones.
    • Combine event triggers with other triggers (like subsystem conditions) for complex logic.

    Warning: If you bind a command to an EventTrigger that shares requirements with commands in the auto command group, the auto command group will be interrupted when the EventTrigger is triggered.

    from pathplannerlib.events import EventTrigger
    
    # Bind a command to run while an event is active
    EventTrigger('run intake').whileTrue(cmd.print('running intake'))
    
    # Combine an event trigger with a subsystem condition
    EventTrigger('shoot note').and(Trigger(self.exampleSubsystem.someCondition)).onTrue(cmd.print('shoot note'))
  10. How the Swerve Setpoint Generator works

    main

    The SwerveSetpointGenerator is a tool used to calculate safe swerve module targets. It takes a prior setpoint and a desired setpoint, then outputs a new setpoint that respects the robot's physical kinematic constraints.

    Key features include:

    • Torque-limited acceleration: Module acceleration is constrained by the maximum torque the motor can output.
    • Friction-aware torque: Maximum module torque is limited by the friction between the wheels and the carpet to prevent wheel slip.
    • Centripetal force limiting: Module rotation is limited to ensure centripetal force stays within the friction limits, preventing sliding during curves.
    • Internal friction compensation: Accounts for internal module friction, which affects maximum acceleration and deceleration capabilities.