Class MoveToPose
- All Implemented Interfaces:
Sendable
HolonomicDriveController.
This command continuously computes robot-relative chassis speeds that reduce translational and
rotational error to a target Pose2d. The command finishes once the robot is within the
specified translation and rotation tolerances.
The target pose may be supplied dynamically (e.g., from vision or an autonomous routine). An optional alliance-based pose flip can be applied automatically for red alliance operation.
Output chassis speeds are robot-relative and are clamped to a configurable maximum translational speed.
This command is typically created via Swerve.moveToPose(...) and should not be
instantiated directly.
-
Nested Class Summary
Nested classes/interfaces inherited from class edu.wpi.first.wpilibj2.command.Command
Command.InterruptionBehavior -
Constructor Summary
ConstructorsConstructorDescriptionMoveToPose(Swerve swerve, Consumer<ChassisSpeeds> robotRelativeConsumer, Supplier<Pose2d> target, @Nullable choreo.auto.AutoRoutine autoRoutine, DoubleSupplier maxSpeed, boolean flipForRed, double translationTolerance, double rotationTolerance) Constructs a command that drives the robot to a target pose. -
Method Summary
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
-
MoveToPose
public MoveToPose(Swerve swerve, Consumer<ChassisSpeeds> robotRelativeConsumer, Supplier<Pose2d> target, @Nullable choreo.auto.AutoRoutine autoRoutine, DoubleSupplier maxSpeed, boolean flipForRed, double translationTolerance, double rotationTolerance) Constructs a command that drives the robot to a target pose.Note: This constructor is intended for use by generated builders. Prefer
Swerve.moveToPose(...)when creating this command.- Parameters:
swerve- drivetrain subsystem providing pose estimationrobotRelativeConsumer- consumer that accepts robot-relative chassis speedstarget- supplier providing the desired field-relative target poseautoRoutine- optional autonomous routine used to scope triggersmaxSpeed- supplier providing the maximum allowed translational speed (m/s)flipForRed- whether to mirror the target pose for red alliancetranslationTolerance- allowable positional error (meters)rotationTolerance- allowable angular error (radians)
-
-
Method Details
-
active
Returns a trigger that istruewhile this command is actively running.If associated with an
AutoRoutine, the trigger is also gated by the routine's active state.- Returns:
- trigger indicating whether the command is currently active
-
done
Returns a trigger that becomestrueonce the command has completed successfully.The trigger remains
trueuntil the command is restarted.- Returns:
- trigger indicating completion of the command
-
initialize
public void initialize()- Overrides:
initializein classCommand
-
execute
public void execute() -
end
public void end(boolean interrupted) -
isFinished
public boolean isFinished()- Overrides:
isFinishedin classCommand
-