Class DriveFacingBestObject
java.lang.Object
edu.wpi.first.wpilibj2.command.Command
frc.alotobots.library.subsystems.vision.photonvision.objectdetection.commands.DriveFacingBestObject
- All Implemented Interfaces:
Sendable
A command that automatically rotates the robot to face detected game objects while allowing
manual translation control. The robot will face the highest priority detected game element while
driving. If no objects are detected, or if manual rotation override is active, falls back to
standard manual control.
-
Nested Class Summary
Nested classes/interfaces inherited from class edu.wpi.first.wpilibj2.command.Command
Command.InterruptionBehavior
-
Constructor Summary
ConstructorDescriptionDriveFacingBestObject
(ObjectDetectionSubsystem objectDetectionSubsystem, SwerveDriveSubsystem swerveDriveSubsystem, GameElement... targetGameElementNames) Creates a new DriveFacingBestObject command. -
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
Executes the command logic.boolean
Determines if the command should end.Methods inherited from class edu.wpi.first.wpilibj2.command.Command
addRequirements, addRequirements, alongWith, andThen, andThen, asProxy, beforeStarting, beforeStarting, cancel, deadlineFor, deadlineWith, end, finallyDo, finallyDo, getInterruptionBehavior, getName, getRequirements, getSubsystem, handleInterrupt, hasRequirement, ignoringDisable, initialize, initSendable, isScheduled, onlyIf, onlyWhile, raceWith, repeatedly, runsWhenDisabled, schedule, setName, setSubsystem, unless, until, withInterruptBehavior, withName, withTimeout, withTimeout
-
Constructor Details
-
DriveFacingBestObject
public DriveFacingBestObject(ObjectDetectionSubsystem objectDetectionSubsystem, SwerveDriveSubsystem swerveDriveSubsystem, GameElement... targetGameElementNames) Creates a new DriveFacingBestObject command.- Parameters:
objectDetectionSubsystem
- Subsystem used for detecting game objectsswerveDriveSubsystem
- Subsystem used for robot movementtargetGameElementNames
- Array of game elements to target, in priority order
-
-
Method Details
-
execute
public void execute()Executes the command logic. Gets the latest object detections and controls robot movement: - If objects are detected, rotates to face highest priority object while allowing manual translation - If no objects detected, allows full manual control - If manual rotation override active, starts timeout timer -
isFinished
public boolean isFinished()Determines if the command should end.- Overrides:
isFinished
in classCommand
- Returns:
- true if manual rotation override timeout has elapsed
-