Class Vision

java.lang.Object
frc.lib.service.BaseService
frc.robot.services.vision.Vision
All Implemented Interfaces:
Monitored

public class Vision extends BaseService implements Monitored
Service for processing vision data, specifically from AprilTag cameras.

Receives raw camera detections, filters them based on quality (tag count), and feeds valid measurements into the Drive subsystem's pose estimator to refine the robot's field position. Also monitors camera health and status using highly optimized zero-allocation data structures.

  • Constructor Details

    • Vision

      public Vision(VisionIO io)
      Creates a new Vision service.
      Parameters:
      io - The abstraction layer for the vision hardware.
  • Method Details

    • broadcastTelemetry

      public void broadcastTelemetry(IMUState imuState)
      Forwards a high frequency IMU packet to the vision pipeline.
      Parameters:
      imuState - The current 6-DOF IMU state.
    • update

      public void update()
      Processes vision measurements, filters invalid data, updates the drive pose estimator, and checks camera status.
      Specified by:
      update in class BaseService
    • isHealthy

      public boolean isHealthy()
      Returns whether or not the service is healthy
      Specified by:
      isHealthy in interface Monitored
      Returns:
      True if the service is healthy, false otherwise.
    • clearFaults

      public void clearFaults()
      Clear all faults and reset the service.
      Specified by:
      clearFaults in interface Monitored
    • setVisionMeasurementConsumer

      public void setVisionMeasurementConsumer(Vision.VisionMeasurementConsumer consumer)
      Sets the consumer for vision measurements.
      Parameters:
      consumer - A callback function that will be called with each valid vision measurement, providing the pose, timestamp, and standard deviations. This allows external systems to react to new vision data in real-time.