Class MoveToPose

java.lang.Object
edu.wpi.first.wpilibj2.command.Command
frc.robot.subsystems.swerve.util.MoveToPose
All Implemented Interfaces:
Sendable

@NullMarked public class MoveToPose extends Command
Command that drives a swerve drivetrain to a specified field-relative pose using a 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.

  • 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 estimation
      robotRelativeConsumer - consumer that accepts robot-relative chassis speeds
      target - supplier providing the desired field-relative target pose
      autoRoutine - optional autonomous routine used to scope triggers
      maxSpeed - supplier providing the maximum allowed translational speed (m/s)
      flipForRed - whether to mirror the target pose for red alliance
      translationTolerance - allowable positional error (meters)
      rotationTolerance - allowable angular error (radians)
  • Method Details

    • active

      public Trigger active()
      Returns a trigger that is true while 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

      public Trigger done()
      Returns a trigger that becomes true once the command has completed successfully.

      The trigger remains true until the command is restarted.

      Returns:
      trigger indicating completion of the command
    • initialize

      public void initialize()
      Overrides:
      initialize in class Command
    • execute

      public void execute()
      Overrides:
      execute in class Command
    • end

      public void end(boolean interrupted)
      Overrides:
      end in class Command
    • isFinished

      public boolean isFinished()
      Overrides:
      isFinished in class Command