java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
frc.alotobots.library.subsystems.vision.photonvision.objectdetection.ObjectDetectionSubsystem
All Implemented Interfaces:
Sendable, Subsystem

public class ObjectDetectionSubsystem extends SubsystemBase
Subsystem that handles object detection using PhotonVision cameras. This subsystem processes camera inputs to track and identify objects in the field, maintaining lists of both stable and pending object detections.
  • Constructor Details

    • ObjectDetectionSubsystem

      public ObjectDetectionSubsystem(Supplier<Pose2d> robotPose, ObjectDetectionIO... io)
      Creates a new ObjectDetectionSubsystem.
      Parameters:
      robotPose - Supplier for the current robot pose
      io - Array of ObjectDetectionIO interfaces for cameras
  • Method Details

    • periodic

      public void periodic()
      Periodic function that updates camera inputs and processes detections.
    • toPoseArray

      public Pose3d[] toPoseArray(ObjectDetectionIO.DetectedObjectFieldRelative[] detectedObjects)
      Converts an array of detected objects to an array of their poses.
      Parameters:
      detectedObjects - Array of detected objects
      Returns:
      Array of object poses
    • toFieldRelative

      Converts robot-relative object detections to field-relative coordinates.
      Parameters:
      robotRelative - Array of robot-relative object detections
      Returns:
      Array of field-relative object detections
    • getDetectedObjects

      public List<ObjectDetectionIO.DetectedObjectFieldRelative> getDetectedObjects(boolean includeUnstable, boolean includeStable)
      Gets a list of detected objects based on stability criteria.
      Parameters:
      includeUnstable - Whether to include unstable/pending objects
      includeStable - Whether to include stable objects
      Returns:
      List of detected objects matching the criteria
    • getStableDetectedObjects

      public List<ObjectDetectionIO.DetectedObjectFieldRelative> getStableDetectedObjects()
      Gets a list of only stable detected objects.
      Returns:
      List of stable detected objects
    • getUnstableDetectedObjects

      public List<ObjectDetectionIO.DetectedObjectFieldRelative> getUnstableDetectedObjects()
      Gets a list of only unstable/pending detected objects.
      Returns:
      List of unstable detected objects
    • getAllDetectedObjects

      public List<ObjectDetectionIO.DetectedObjectFieldRelative> getAllDetectedObjects()
      Gets a list of all detected objects, both stable and unstable.
      Returns:
      List of all detected objects