Class LimelightWrapper
java.lang.Object
yall.VisionCamera
yall.cameras.LimelightWrapper
- All Implemented Interfaces:
AutoCloseable
A Limelight, through LimelightLib 2.
Pose estimates are MegaTag1 for PoseEstimationMode.TAGS_ONLY and MegaTag2 for PoseEstimationMode.HEADING_ASSISTED, in WPILib blue-origin coordinates. The config's
robot-to-camera transform, if set, overrides the camera pose from the Limelight web interface.
Vendor configs accepted by VisionCameraConfig.withVendorConfig(Object):
PoseEstimateConfig: Limelight's own pose filter and standard deviations replace YALL'sVisionPoseFilterfor this camera.PipelineConfiguration: applied as a pipeline override.
Without a camera model in the config, it is simulated as a CameraModel.LIMELIGHT_4.
This wrapper reads Limelight.readResultsQueue(), so don't read any of the Limelight's
queues elsewhere: each frame is handed out only once.
-
Field Summary
Fields inherited from class VisionCamera
config, name -
Constructor Summary
ConstructorsConstructorDescriptionLimelightWrapper(com.limelightvision.Limelight limelight, VisionCameraConfig config) Wraps a Limelight. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyPipelineIndex(int index) Switches the real camera's pipeline.protected voidapplyRobotOrientation(double timestampSeconds, Rotation3d orientation, double yawRateDegreesPerSecond) Passes the robot orientation to the real camera, for cameras that use it themselves.protected voidapplyRobotToCamera(Transform3d robotToCamera) Passes a new camera position to the real camera, for cameras that use it themselves.com.limelightvision.LimelightThe vendor's camera object, for settings YALL doesn't cover.protected booleanWhether the real camera is sending data.protected List<VisionFrame> Reads the frames the real camera produced since the last call.protected intReads the real camera's pipeline.voidsetRobotToCameraAndOrientation(Transform3d robotToCamera, Rotation3d orientation, AngularVelocity yawRate) Updates both a moving/turret-mounted camera's robot-to-camera transform and the robot's orientation in a single NetworkTables flush so MegaTag2 receives both values atomically.Methods inherited from class VisionCamera
addVisionMeasurements, cacheRobotToCamera, checkEstimate, close, forEachEstimatedPose, getBestTarget, getCameraFieldPose, getCameraSim, getCameraYawOnRobot, getConfig, getEstimatedPose, getEstimatedPoses, getFilterStats, getLastRejectionReason, getLatestResult, getName, getPipelineIndex, getRejectedPoses, getRobotToCamera, getSimulatedPoseEstimator, getTargets, getUnreadResults, getVisionSim, hasTargets, isConnected, isSimulated, resetFilterStats, setPipelineIndex, setRobotOrientation, setRobotOrientation, setRobotOrientation, setRobotToCamera, setRobotToCamera, update
-
Constructor Details
-
LimelightWrapper
Wraps a Limelight.- Parameters:
limelight- The Limelight.config- The camera's config.
-
-
Method Details
-
readFrames
Description copied from class:VisionCameraReads the frames the real camera produced since the last call. Call once per loop.- Specified by:
readFramesin classVisionCamera- Returns:
- The frames, oldest first.
-
applyPipelineIndex
protected void applyPipelineIndex(int index) Description copied from class:VisionCameraSwitches the real camera's pipeline.- Specified by:
applyPipelineIndexin classVisionCamera- Parameters:
index- Pipeline index.
-
readPipelineIndex
protected int readPipelineIndex()Description copied from class:VisionCameraReads the real camera's pipeline.- Specified by:
readPipelineIndexin classVisionCamera- Returns:
- Pipeline index.
-
readConnected
protected boolean readConnected()Description copied from class:VisionCameraWhether the real camera is sending data.- Specified by:
readConnectedin classVisionCamera- Returns:
- true if connected.
-
applyRobotOrientation
protected void applyRobotOrientation(double timestampSeconds, Rotation3d orientation, double yawRateDegreesPerSecond) Description copied from class:VisionCameraPasses the robot orientation to the real camera, for cameras that use it themselves.- Overrides:
applyRobotOrientationin classVisionCamera- Parameters:
timestampSeconds- When the orientation was measured.orientation- Robot orientation on the field.yawRateDegreesPerSecond- Yaw rate, or NaN if unknown.
-
applyRobotToCamera
Description copied from class:VisionCameraPasses a new camera position to the real camera, for cameras that use it themselves.- Overrides:
applyRobotToCamerain classVisionCamera- Parameters:
robotToCamera- Transform from the robot origin to the camera.
-
getCamera
public com.limelightvision.Limelight getCamera()Description copied from class:VisionCameraThe vendor's camera object, for settings YALL doesn't cover. Each wrapper narrows the return type to its vendor's class.- Specified by:
getCamerain classVisionCamera- Returns:
- The vendor's camera object.
-
setRobotToCameraAndOrientation
public void setRobotToCameraAndOrientation(Transform3d robotToCamera, Rotation3d orientation, AngularVelocity yawRate) Updates both a moving/turret-mounted camera's robot-to-camera transform and the robot's orientation in a single NetworkTables flush so MegaTag2 receives both values atomically.- Parameters:
robotToCamera- Current transform from the robot origin to the camera.orientation- Current robot orientation on the field: the yaw from your pose estimator, the roll and pitch from the gyro.yawRate- Current robot yaw rate.
-