Class PathfindToBestObject
java.lang.Object
edu.wpi.first.wpilibj2.command.Command
frc.alotobots.library.subsystems.vision.photonvision.objectdetection.commands.PathfindToBestObject
- All Implemented Interfaces:
Sendable
A command that automatically navigates the robot to the best detected game object. The robot will
pathfind to an offset position near the highest priority detected game element, accounting for
robot bumper dimensions when calculating the final position.
-
Nested Class Summary
Nested classes/interfaces inherited from class edu.wpi.first.wpilibj2.command.Command
Command.InterruptionBehavior
-
Constructor Summary
ConstructorDescriptionPathfindToBestObject
(ObjectDetectionSubsystem objectDetectionSubsystem, SwerveDriveSubsystem swerveDriveSubsystem, PathPlannerManager pathPlannerManager, GameElement... targetGameElementNames) Creates a new PathfindToBestObject 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
-
PathfindToBestObject
public PathfindToBestObject(ObjectDetectionSubsystem objectDetectionSubsystem, SwerveDriveSubsystem swerveDriveSubsystem, PathPlannerManager pathPlannerManager, GameElement... targetGameElementNames) Creates a new PathfindToBestObject 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 generates path: - Finds highest priority detected object - Calculates offset position accounting for robot bumper dimensions - Generates and executes pathfinding command to target position -
isFinished
public boolean isFinished()Determines if the command should end.- Overrides:
isFinished
in classCommand
- Returns:
- true if timeout has elapsed
-