Class DrivePrecisionAlign

java.lang.Object
frc.alotobots.library.subsystems.swervedrive.commands.DrivePrecisionAlign

public class DrivePrecisionAlign extends Object
Handles precision alignment requests to a target pose using PathPlanner's holonomic drive controller.
  • Constructor Details

    • DrivePrecisionAlign

      public DrivePrecisionAlign(SwerveDriveSubsystem swerveDriveSubsystem, Supplier<Pose2d> currentPoseSupplier, double positionTolerance)
      Creates a new PrecisionAlignRequest handler.
      Parameters:
      swerveDriveSubsystem - The drive subsystem
      currentPoseSupplier - The source to use for pose
      positionTolerance - The position tolerance for considering alignment complete (meters)
    • DrivePrecisionAlign

      public DrivePrecisionAlign(SwerveDriveSubsystem swerveDriveSubsystem, Supplier<Pose2d> currentPoseSupplier)
      Creates a new PrecisionAlignRequest handler with default tolerance.
      Parameters:
      swerveDriveSubsystem - The drive subsystem
      currentPoseSupplier - Where to get the current pose from
    • DrivePrecisionAlign

      public DrivePrecisionAlign(SwerveDriveSubsystem swerveDriveSubsystem)
      Creates a new PrecisionAlignRequest handler with default tolerance.
      Parameters:
      swerveDriveSubsystem - The drive subsystem
  • Method Details

    • setup

      public void setup()
      Called to initialize the request handler.
    • applyRequest

      public void applyRequest(Supplier<Pose2d> targetPose)
      Applies the precision alignment request.
      Parameters:
      targetPose - Supplier for the target pose to align to
    • isNearTarget

      public boolean isNearTarget()
      Checks if the robot is near the current target pose within the position tolerance.
      Returns:
      True if the robot is within the position tolerance of the current target
    • isNearTarget

      public boolean isNearTarget(Pose2d targetPose)
      Checks if the robot is near the specified target pose within the position tolerance.
      Parameters:
      targetPose - The target pose to check against
      Returns:
      True if the robot is within the position tolerance of the target
    • getCommand

      public Command getCommand(Supplier<Pose2d> targetPose)
      Creates a command that executes the precision alignment.
      Parameters:
      targetPose - Supplier for the target pose to align to
      Returns:
      A command that will execute the precision alignment
    • getCommand

      public Command getCommand(Pose2d targetPose)
      Creates a command that executes the precision alignment to a fixed pose.
      Parameters:
      targetPose - The fixed target pose to align to
      Returns:
      A command that will execute the precision alignment