java.lang.Object
edu.wpi.first.wpilibj2.command.Command
frc.alotobots.library.subsystems.vision.photonvision.objectdetection.commands.PathfindToBestObject
All Implemented Interfaces:
Sendable

public class PathfindToBestObject extends Command
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.
  • 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 objects
      swerveDriveSubsystem - Subsystem used for robot movement
      targetGameElementNames - 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
      Overrides:
      execute in class Command
    • isFinished

      public boolean isFinished()
      Determines if the command should end.
      Overrides:
      isFinished in class Command
      Returns:
      true if timeout has elapsed