Class SimVision
java.lang.Object
frc.robot.subsystems.vision.SimVision
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classOne simulated Limelight: PhotonLib results read once per loop, shared by MT1 and MT2.static final classA Limelight source backed by a PhotonLib sim camera.static final classSimulated QuestNav: reports truth in its own frame, which lines up with the field only afterSimVision.QuestSimIO.resetPose(Pose2d), plus a random-walk drift. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.photonvision.PhotonCameraaddCamera(String name, org.photonvision.simulation.SimCameraProperties properties, Transform3d robotToCamera) Adds a simulated camera that publishes as a PhotonVision camera namedname.Field2d showing what PhotonLib's sim sees (tags, cameras, robot).static org.photonvision.simulation.SimCameraPropertiesProperties of a Limelight 4 (1280x800, ~82 deg diagonal), per Limelight's spec sheet.static Transform3dA Limelight's mount in WPILib's robot frame (x forward, y left, z up).static org.photonvision.simulation.SimCameraPropertiesProperties of a Thrifty Bot Thriftiest Cam (OV9281, 1280x800) as the Orin runs it.voidupdate()Moves every simulated camera to the current truth pose.
-
Constructor Details
-
SimVision
- Parameters:
layout- field tagstruth- simulated true robot pose
-
-
Method Details
-
update
public void update()Moves every simulated camera to the current truth pose. Call once per loop, first. -
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 namedname.- Parameters:
name- camera name on NetworkTablesproperties- sensor modelrobotToCamera- mount- Returns:
- the PhotonLib camera handle, to read results from
-
robotToCamera
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.
-