Class SimVision

java.lang.Object
frc.robot.subsystems.vision.SimVision

public class SimVision extends Object
Simulated cameras for every pose source, on PhotonLib's VisionSystemSim.

One PhotonLib vision system holds every AprilTag camera on the robot, the Limelights as well as the Orin's cameras, each with its own mount and camera properties. All of them look at the 2026 field from the simulated truth pose (see Swerve.SimErrors). The Orin cameras are read exactly as on the robot, by PhotonOrinIO over NetworkTables. The Limelights are read by SimVision.LimelightSimIO, which turns the same PhotonLib results into what a Limelight reports:

  • MegaTag1 uses the multi-tag (or single-tag) solve, heading included.
  • MegaTag2 solves translation from each tag with the heading the robot pushed, which is how MegaTag2 works and why it inherits gyro drift.
  • Target size reports the largest target's area, as ta.

The QuestNav is SimVision.QuestSimIO: truth plus a slow random-walk drift, in a field frame that only lines up once the robot has sent a pose reset. Those are the two things a VIO source gets wrong.

  • Constructor Details

  • Method Details

    • update

      public void update()
      Moves every simulated camera to the current truth pose. Call once per loop, first.
    • getDebugField

      public Field2d getDebugField()
      Field2d showing what PhotonLib's sim sees (tags, cameras, robot).
    • limelight4

      public static org.photonvision.simulation.SimCameraProperties limelight4()
      Properties of a Limelight 4 (1280x800, ~82 deg diagonal), per Limelight's spec sheet.
    • thriftiestCam

      public static org.photonvision.simulation.SimCameraProperties thriftiestCam()
      Properties of a Thrifty Bot Thriftiest Cam (OV9281, 1280x800) as the Orin runs it.
    • addCamera

      public org.photonvision.PhotonCamera addCamera(String name, org.photonvision.simulation.SimCameraProperties properties, Transform3d robotToCamera)
      Adds a simulated camera that publishes as a PhotonVision camera named name.
      Parameters:
      name - camera name on NetworkTables
      properties - sensor model
      robotToCamera - mount
      Returns:
      the PhotonLib camera handle, to read results from
    • robotToCamera

      public static Transform3d robotToCamera(Limelight.LimelightConfig c)
      A Limelight's mount in WPILib's robot frame (x forward, y left, z up). Limelight's own convention is forward, right, up and pitch positive up; WPILib's pitch is positive down.