Class VisionCameraConfig
java.lang.Object
yall.VisionCameraConfig
Settings shared by every
VisionCamera, whatever the vendor.
VisionCameraConfig config = new VisionCameraConfig()
.withRobotToCamera(Inches.of(12), Inches.of(0), Inches.of(10),
Degrees.of(0), Degrees.of(-15), Degrees.of(0))
.withPoseEstimationMode(PoseEstimationMode.HEADING_ASSISTED)
.withPoseFilter(new VisionPoseFilter().withMaxAmbiguity(0.15));
Vendor settings that YALL doesn't cover go through withVendorConfig(Object), or
straight to the vendor object from VisionCamera.getCamera().
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a config with the defaults: no camera offset, the current season's field. -
Method Summary
Modifier and TypeMethodDescriptionOptional<org.photonvision.simulation.SimCameraProperties> Camera properties.getField()The field holding the AprilTag layout.Pipeline to switch to on creation.How AprilTags become a robot pose.The pose estimate filter.Transform from the robot origin to the camera.What the camera publishes to NetworkTables.Vendor config object.The simulated world.booleanWhether the simulated camera streams video.booleanWhether the simulated video streams draw the field.booleanWhether the camera is simulated in simulation.booleanWhether the camera publishes telemetry.withCameraModel(CameraModel model) Sets the camera's resolution, field of view and frame rate from a camera's published specs.withCameraProperties(int widthPixels, int heightPixels, Angle diagonalFov, Frequency frameRate) Sets the camera's resolution and diagonal field of view, keeping the rest of the default camera properties.withCameraProperties(org.photonvision.simulation.SimCameraProperties properties) Sets the camera's resolution, field of view, frame rate, latency and noise.Sets the field, which holds the AprilTag layout.withPipelineIndex(int index) Sets the pipeline to switch to when the camera is created.Sets how AprilTags become a robot pose.withPoseFilter(VisionPoseFilter filter) Sets the filter that accepts or rejects pose estimates and weighs them.withRobotToCamera(Transform3d robotToCamera) Sets where the camera is on the robot.Sets where the camera is on the robot, measured from the robot's center on the floor.withSimulatedVideoStreams(boolean enabled) Sets whether the simulated camera streams what it would see: PhotonVision draws the AprilTags (and, withwithSimulatedWireframe(boolean), the field) from the camera's point of view.withSimulatedWireframe(boolean enabled) Sets whether the simulated video streams also draw the field's floor and walls, which helps to see where the camera points.withSimulation(boolean enabled) Sets whether the camera gives simulated results when the robot program runs in simulation.withSimulation(VisionSim sim) Sets the simulated world the camera belongs to.withTelemetry(boolean enabled) Sets whether the camera publishes telemetry to NetworkTables, with the defaultVisionTelemetryConfig: everyTelemetryVerbosity.MIDfield underYALL/<camera name>.withTelemetry(VisionTelemetryConfig telemetryConfig) Sets what the camera publishes to NetworkTables and logs to a DataLog, and where.withVendorConfig(Object vendorConfig) Passes a vendor config object to the camera, as YAMS does for motor controllers.
-
Constructor Details
-
VisionCameraConfig
public VisionCameraConfig()Creates a config with the defaults: no camera offset, the current season's field.
-
-
Method Details
-
withRobotToCamera
Sets where the camera is on the robot. Pose estimates, simulation and Synapse's robot pose all need it. On a Limelight it overrides the camera pose set in the web interface.- Parameters:
robotToCamera- Transform from the robot origin to the camera lens.- Returns:
- This config, for chaining.
-
withRobotToCamera
public VisionCameraConfig withRobotToCamera(Distance forward, Distance left, Distance up, Angle roll, Angle pitch, Angle yaw) Sets where the camera is on the robot, measured from the robot's center on the floor. The arguments follow the order of Limelight's own camera pose: forward, left, up, then roll, pitch, yaw.config.withRobotToCamera( Inches.of(12), Inches.of(0), Inches.of(10), // 12" forward, centered, 10" up Degrees.of(0), Degrees.of(-15), Degrees.of(0)); // tilted 15° up- Parameters:
forward- Distance forward of the robot center. Negative is behind it.left- Distance left of the robot center. Negative is right of it.up- Height above the floor.roll- Rotation about the camera's forward axis, counterclockwise positive.pitch- Rotation about the left axis. Negative tilts the camera up.yaw- Rotation about the up axis, counterclockwise positive. 180° faces backward.- Returns:
- This config, for chaining.
- See Also:
-
withField
Sets the field, which holds the AprilTag layout. Defaults to WPILib'sFields.DEFAULT_FIELD.- Parameters:
field- The field.- Returns:
- This config, for chaining.
-
withPoseEstimationMode
Sets how AprilTags become a robot pose. Defaults toPoseEstimationMode.TAGS_ONLY.- Parameters:
mode- The pose estimation mode.- Returns:
- This config, for chaining.
-
withPoseFilter
Sets the filter that accepts or rejects pose estimates and weighs them. Defaults to a newVisionPoseFilter, which has every standard check on.- Parameters:
filter- The filter.- Returns:
- This config, for chaining.
-
withPipelineIndex
Sets the pipeline to switch to when the camera is created.- Parameters:
index- Pipeline index.- Returns:
- This config, for chaining.
-
withCameraProperties
public VisionCameraConfig withCameraProperties(org.photonvision.simulation.SimCameraProperties properties) Sets the camera's resolution, field of view, frame rate, latency and noise. Simulation uses them, and Synapse uses them to turn pixel positions into angles. Each vendor wrapper has a default;withCameraModel(CameraModel)sets them from a camera's published specs.- Parameters:
properties- PhotonVision camera properties.- Returns:
- This config, for chaining.
-
withCameraModel
Sets the camera's resolution, field of view and frame rate from a camera's published specs. Use the model that matches the real camera, so simulation sees what it would.- Parameters:
model- The camera model.- Returns:
- This config, for chaining.
-
withCameraProperties
public VisionCameraConfig withCameraProperties(int widthPixels, int heightPixels, Angle diagonalFov, Frequency frameRate) Sets the camera's resolution and diagonal field of view, keeping the rest of the default camera properties.- Parameters:
widthPixels- Image width.heightPixels- Image height.diagonalFov- Diagonal field of view.frameRate- Frame rate.- Returns:
- This config, for chaining.
-
withSimulation
Sets whether the camera gives simulated results when the robot program runs in simulation. Defaults to true.- Parameters:
enabled- true to simulate.- Returns:
- This config, for chaining.
-
withSimulation
Sets the simulated world the camera belongs to. Defaults toVisionSim.getDefault().- Parameters:
sim- The simulated world.- Returns:
- This config, for chaining.
-
withSimulatedVideoStreams
Sets whether the simulated camera streams what it would see: PhotonVision draws the AprilTags (and, withwithSimulatedWireframe(boolean), the field) from the camera's point of view. The streams cost CPU, so they default to off.The streams are served by WPILib's CameraServer as
YALL-<camera name>-rawandYALL-<camera name>-processed(<camera name>-rawand-processedfor a PhotonVision camera). Open them in a dashboard's camera stream widget, or in a browser athttp://localhost:1181,1182and up, one port per stream in the order they were made.- Parameters:
enabled- true to stream raw and processed simulated video.- Returns:
- This config, for chaining.
-
withSimulatedWireframe
Sets whether the simulated video streams also draw the field's floor and walls, which helps to see where the camera points. Drawing them costs more CPU than the AprilTags alone, so it defaults to off. Has no effect unlesswithSimulatedVideoStreams(boolean)is on.- Parameters:
enabled- true to draw the field.- Returns:
- This config, for chaining.
-
withVendorConfig
Passes a vendor config object to the camera, as YAMS does for motor controllers. Each wrapper documents the types it accepts and throwsIllegalArgumentExceptionfor others.- Parameters:
vendorConfig- Vendor config object.- Returns:
- This config, for chaining.
-
withTelemetry
Sets whether the camera publishes telemetry to NetworkTables, with the defaultVisionTelemetryConfig: everyTelemetryVerbosity.MIDfield underYALL/<camera name>. Defaults to true.- Parameters:
enabled- true to publish.- Returns:
- This config, for chaining.
-
withTelemetry
Sets what the camera publishes to NetworkTables and logs to a DataLog, and where.- Parameters:
telemetryConfig- What to publish, or null to publish nothing.- Returns:
- This config, for chaining.
-
getRobotToCamera
Transform from the robot origin to the camera.- Returns:
- The transform, if set.
-
getField
The field holding the AprilTag layout.- Returns:
- The configured field, or
Fields.DEFAULT_FIELD.
-
getPoseEstimationMode
How AprilTags become a robot pose.- Returns:
- The pose estimation mode.
-
getPoseFilter
-
getPipelineIndex
-
getCameraProperties
Camera properties.- Returns:
- The properties, if set.
-
isSimulationEnabled
public boolean isSimulationEnabled()Whether the camera is simulated in simulation.- Returns:
- true to simulate.
-
getVisionSim
-
isSimulatedVideoStreamsEnabled
public boolean isSimulatedVideoStreamsEnabled()Whether the simulated camera streams video.- Returns:
- true to stream.
-
isSimulatedWireframeEnabled
public boolean isSimulatedWireframeEnabled()Whether the simulated video streams draw the field.- Returns:
- true to draw the field.
-
getVendorConfig
-
isTelemetryEnabled
public boolean isTelemetryEnabled()Whether the camera publishes telemetry.- Returns:
- true to publish.
-
getTelemetryConfig
What the camera publishes to NetworkTables.- Returns:
- The telemetry config, or empty to publish nothing.
-