Class DrivePrecisionAlign
java.lang.Object
frc.alotobots.library.subsystems.swervedrive.commands.DrivePrecisionAlign
Handles precision alignment requests to a target pose using PathPlanner's holonomic drive
controller.
-
Constructor Summary
ConstructorsConstructorDescriptionDrivePrecisionAlign
(SwerveDriveSubsystem swerveDriveSubsystem) Creates a new PrecisionAlignRequest handler with default tolerance.DrivePrecisionAlign
(SwerveDriveSubsystem swerveDriveSubsystem, Supplier<Pose2d> currentPoseSupplier) Creates a new PrecisionAlignRequest handler with default tolerance.DrivePrecisionAlign
(SwerveDriveSubsystem swerveDriveSubsystem, Supplier<Pose2d> currentPoseSupplier, double positionTolerance) Creates a new PrecisionAlignRequest handler. -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyRequest
(Supplier<Pose2d> targetPose) Applies the precision alignment request.getCommand
(Pose2d targetPose) Creates a command that executes the precision alignment to a fixed pose.getCommand
(Supplier<Pose2d> targetPose) Creates a command that executes the precision alignment.boolean
Checks if the robot is near the current target pose within the position tolerance.boolean
isNearTarget
(Pose2d targetPose) Checks if the robot is near the specified target pose within the position tolerance.void
setup()
Called to initialize the request handler.
-
Constructor Details
-
DrivePrecisionAlign
public DrivePrecisionAlign(SwerveDriveSubsystem swerveDriveSubsystem, Supplier<Pose2d> currentPoseSupplier, double positionTolerance) Creates a new PrecisionAlignRequest handler.- Parameters:
swerveDriveSubsystem
- The drive subsystemcurrentPoseSupplier
- The source to use for posepositionTolerance
- 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 subsystemcurrentPoseSupplier
- Where to get the current pose from
-
DrivePrecisionAlign
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
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
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
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
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
-