-
Notifications
You must be signed in to change notification settings - Fork 163
Python Example: Register Named Commands
Michael Jansen edited this page Dec 7, 2023
·
1 revision
You must register your named commands so that they can be used in the creation of Event Markers and Autos. All of your named commands need to be registered before you create a PathPlanner path or auto in your code. Failure to do so would mean that any named command registered after path/auto creation will not be used in those paths and autos. A recommended place to do this would be in RobotContainer, after the initialization of your subsystems and before the initialization of any commands that use PathPlanner.
All named commands are registered via static methods in the NamedCommands class. The string used when registering a command should be identical to the one used in the PathPlanner GUI.
from pathplannerlib.auto import NamedCommands
class RobotContainer:
def __init__(self):
# Subsystem initialization
self.swerve = Swerve()
self.exampleSubsystem = ExampleSubsystem()
# Register Named Commands
NamedCommands.registerCommand('autoBalance', swerve.autoBalanceCommand())
NamedCommands.registerCommand('exampleCommand', exampleSubsystem.exampleCommand())
NamedCommands.registerCommand('someOtherCommand', SomeOtherCommand())
# Do all other initialization
self.configureButtonBindings()
# ...- Controls & Shortcuts
- Editing Paths & Autos
- Navigation Menu
- Settings
- Project Browser
- Telemetry Page
- Navigation Grid Editor
- Register Named Commands
- Build an Auto
- Follow a Single Path
- Create a Path On-the-fly
- Path Groups
- Automatic Pathfinding
Advanced Usage
- Register Named Commands
- Build an Auto
- Follow a Single Path
- Create a Path On-the-fly
- Path Groups
- Automatic Pathfinding
Advanced Usage
- Register Named Commands
- Build an Auto
- Follow a Single Path
- Create a Path On-the-fly
- Path Groups
- Automatic Pathfinding