Object Detection Subsystem
The Object Detection subsystem is a vision processing system that uses PhotonVision to detect and track game objects on the field in real-time. It maintains lists of both stable (consistently tracked) and pending (newly detected) objects, providing filtered and reliable object detection data to other subsystems.
Constructor
public ObjectDetectionSubsystem(Supplier<Pose2d> robotPose, ObjectDetectionIO... io)
Parameters:
- robotPose
: A supplier function that provides the current robot pose in field coordinates
- io
: One or more ObjectDetectionIO interfaces representing the vision cameras
Related Commands
The following commands utilize this subsystem: - DriveFacingBestObject - Automatically rotates the robot to face detected objects while driving - PathfindToBestObject - Autonomously navigates the robot to approach detected objects
Configuration Requirements
The subsystem requires several constants to be configured in the ObjectDetectionConstants class:
-
Camera Configurations:
CAMERA_CONFIGS
: Array of camera configuration parametersPOSITION_MATCH_TOLERANCE
: Distance threshold for matching detected objectsHISTORY_LENGTH
: Number of frames to keep in detection historyREQUIRED_DETECTIONS
: Number of detections required for stabilityMISSING_FRAMES_THRESHOLD
: Number of missed frames before losing stability
-
Game Element Definitions:
GAME_ELEMENTS
: Array mapping detected class IDs to game elements
-
PhotonVision Configuration:
- Each camera must be properly configured in PhotonVision with:
- Appropriate pipelines for object detection
- Correct camera mounting position and angle
- Calibrated camera parameters
- Each camera must be properly configured in PhotonVision with:
Requirements
- PhotonVision installed and configured on your robot
- At least one compatible camera connected and configured
- WPILib 2024 or newer
For detailed method documentation, refer to the JavaDoc reference.