Class VisionLogger

java.lang.Object
frc.spectrumLib.vision.VisionLogger

public class VisionLogger extends Object
Logs a Limelight camera to the wpilog under the Vision/<name>/ namespace.

Each method reads the value from the camera, forwards it to Telemetry.log(edu.wpi.first.wpilibj2.command.Command), and returns it so callers do not have to query the camera twice.

Log keys are built once in the constructor, so per-loop logging allocates no strings.

  • Constructor Details

  • Method Details

    • getEstimateAge

      public double getEstimateAge()
      Age of this loop's estimate in seconds, or NaN if the camera produced none.
    • getIntegratedThisLoop

      public boolean getIntegratedThisLoop()
      Whether an estimate was actually fused into the pose estimator this loop, as opposed to merely passing the acceptance tiers.
    • getCameraConnection

      public boolean getCameraConnection()
    • getIntegratingStatus

      public boolean getIntegratingStatus()
    • getLogStatus

      public String getLogStatus()
    • getTagStatus

      public String getTagStatus()
    • getPose

      public Pose2d getPose()
      Robot pose from the MegaTag1 estimate, projected to 2-D in the WPILib Blue origin frame.
    • getMegaPose

      public Pose2d getMegaPose()
      Robot pose from the heading-fused MegaTag2 estimate, in the WPILib Blue origin frame.
    • logMountCheck

      public void logMountCheck()
      Logs the out-of-plane part of the MegaTag1 estimate so the camera's mount angles can be checked against the values entered in its web UI.

      MegaTag1 reports the robot's full 3-D pose. It solves the camera's pose from the tag, then applies the camera-to-robot transform from the camera's entered offsets. With the robot sitting flat on the carpet the truth is height 0, pitch 0, roll 0, so whatever these read is the error in the entered mount rotation. TiltDeg is the total angle between the reported robot Z axis and field up, so it equals the magnitude of that error whatever the camera's yaw. A camera entered at 60 deg but really mounted at 55 shows about 5 deg of tilt.

      PitchDeg and RollDeg say which way the error points, but in the robot frame rather than the camera's: a pitch error of d on a camera yawed at psi lands as roll -d*sin(psi) and pitch d*cos(psi). On the rear cameras at yaw +/-135 that splits evenly between the two, and on the turret camera the split rotates with the turret, which is the other reason to read TiltDeg.

      Read these with the robot stationary on a flat floor and at least one tag in view. Real chassis tilt, from an obstacle or from weight transfer under acceleration, shows up here too. Nothing is logged when no tag is in view, so the values do not fall to zero between sightings. The MegaTag1 sample is read once per loop and cached, so this costs nothing beyond getPose().

    • getTagCount

      public double getTagCount()
    • getTargetSize

      public double getTargetSize()
      Area of the primary target as a percentage of the camera image (0-100).
    • getName

      public String getName()
      Namespace prefix used in all telemetry keys (Vision/<name>/...).