Class PathfindThenFollowPathWithDriveOverride
java.lang.Object
edu.wpi.first.wpilibj2.command.Command
frc.alotobots.library.subsystems.swervedrive.util.PathfindThenFollowPathWithDriveOverride
- All Implemented Interfaces:
Sendable
A command that will pathfind to the start of a path and then follow it with driver override
capability. This extends PathPlanner's pathfinding functionality by allowing driver inputs to
take control when needed and dynamically replanning the path when driver control is released.
-
Nested Class Summary
Nested classes/interfaces inherited from class edu.wpi.first.wpilibj2.command.Command
Command.InterruptionBehavior
-
Constructor Summary
ConstructorsConstructorDescriptionPathfindThenFollowPathWithDriveOverride
(com.pathplanner.lib.path.PathPlannerPath goalPath, com.pathplanner.lib.path.PathConstraints constraints, Supplier<Pose2d> poseSupplier, Supplier<ChassisSpeeds> speedsSupplier, BiConsumer<ChassisSpeeds, com.pathplanner.lib.util.DriveFeedforwards> output, com.pathplanner.lib.controllers.PathFollowingController controller, com.pathplanner.lib.config.RobotConfig robotConfig, BooleanSupplier shouldFlipPath, Supplier<ChassisSpeeds> driverInput, double inputDeadband, boolean smoothTransition, double replanWaitTime, Subsystem... requirements) Creates a new PathfindThenFollowPathWithDriveOverride command. -
Method Summary
Modifier and TypeMethodDescriptionvoid
end
(boolean interrupted) Called once when the command ends or is interrupted.void
execute()
Called repeatedly when this command is scheduled to run.void
Called when the command is initially scheduled.boolean
Returns whether this command has finished.boolean
Returns whether the command is currently in pathfinding mode.Methods inherited from class edu.wpi.first.wpilibj2.command.Command
addRequirements, addRequirements, alongWith, andThen, andThen, asProxy, beforeStarting, beforeStarting, cancel, deadlineFor, deadlineWith, finallyDo, finallyDo, getInterruptionBehavior, getName, getRequirements, getSubsystem, handleInterrupt, hasRequirement, ignoringDisable, initSendable, isScheduled, onlyIf, onlyWhile, raceWith, repeatedly, runsWhenDisabled, schedule, setName, setSubsystem, unless, until, withDeadline, withInterruptBehavior, withName, withTimeout, withTimeout
-
Constructor Details
-
PathfindThenFollowPathWithDriveOverride
public PathfindThenFollowPathWithDriveOverride(com.pathplanner.lib.path.PathPlannerPath goalPath, com.pathplanner.lib.path.PathConstraints constraints, Supplier<Pose2d> poseSupplier, Supplier<ChassisSpeeds> speedsSupplier, BiConsumer<ChassisSpeeds, com.pathplanner.lib.util.DriveFeedforwards> output, com.pathplanner.lib.controllers.PathFollowingController controller, com.pathplanner.lib.config.RobotConfig robotConfig, BooleanSupplier shouldFlipPath, Supplier<ChassisSpeeds> driverInput, double inputDeadband, boolean smoothTransition, double replanWaitTime, Subsystem... requirements) Creates a new PathfindThenFollowPathWithDriveOverride command.- Parameters:
goalPath
- The path to followconstraints
- The path constraints to use when pathfindingposeSupplier
- A supplier for the robot's current posespeedsSupplier
- A supplier for the robot's current chassis speedsoutput
- The consumer for the output chassis speedscontroller
- The path following controller to userobotConfig
- The robot configurationshouldFlipPath
- Whether the path should be flipped (e.g., for different alliances)driverInput
- A supplier for driver input as chassis speedsinputDeadband
- The deadband to apply to driver inputssmoothTransition
- Whether to smoothly transition between autonomous and driver controlreplanWaitTime
- Time to wait before replanning after driver input stopsrequirements
- The subsystems required by this command
-
-
Method Details
-
initialize
public void initialize()Called when the command is initially scheduled. Initializes timing mechanisms and starts pathfinding.- Overrides:
initialize
in classCommand
-
execute
public void execute()Called repeatedly when this command is scheduled to run. Handles transitions between autonomous path following and driver control. -
end
public void end(boolean interrupted) Called once when the command ends or is interrupted. Ensures proper cleanup of resources and commands. -
isFinished
public boolean isFinished()Returns whether this command has finished.- Overrides:
isFinished
in classCommand
- Returns:
- True if the command is finished
-
isPathfinding
public boolean isPathfinding()Returns whether the command is currently in pathfinding mode.- Returns:
- True if actively pathfinding, false if in driver control
-