### Initialize and Configure Limelight Camera Source: https://github.com/yet-another-software-suite/yall/blob/main/README.md Initializes a Limelight camera object and sets its LED mode and camera offset. This is a basic setup step for interacting with the Limelight. ```java import limelight.Limelight; import edu.wpi.first.math.geometry.Pose3d; import limelight.LEDMode; // ... Limelight limelight = new Limelight("limelight"); // Set the limelight to use Pipeline LED control, with the Camera offset of 0, and save. limelight.getSettings() .withLimelightLEDMode(LEDMode.PipelineControl) .withCameraOffset(Pose3d.kZero) .save(); ``` -------------------------------- ### Get Limelight NetworkTable Instance (Java) Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/Limelight.html Provides access to the underlying NetworkTable instance used by the Limelight. This allows for direct interaction with the Limelight's network table data. ```java public NetworkTable getNTTable() { // Implementation to get NetworkTable return null; // Placeholder } ``` -------------------------------- ### Limelight get PoseEstimate Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/LimelightPoseEstimator.BotPose.html Fetches the PoseEstimate for a given Limelight camera. Returns an Optional containing the PoseEstimate if available. ```APIDOC ## GET /yet-another-software-suite/yall/limelight/getPoseEstimate ### Description Fetch the PoseEstimate if it exists for the specified Limelight camera. ### Method GET ### Endpoint /yet-another-software-suite/yall/limelight/getPoseEstimate ### Parameters #### Query Parameters - **camera** (Limelight) - Required - The Limelight camera object to use for fetching the PoseEstimate. ### Request Body (Not applicable for this method, parameters are passed via query) ### Response #### Success Response (200) - **PoseEstimate** (Optional) - The current PoseEstimate from the Limelight camera, wrapped in an Optional. #### Response Example ```json { "PoseEstimate": { "translation": { "x": 1.0, "y": 2.0, "z": 0.5 }, "rotation": { "quaternion": { "w": 1.0, "x": 0.0, "y": 0.0, "z": 0.0 } } } } ``` #### Success Response (200) - Empty Optional - **PoseEstimate** (Optional) - An empty Optional if no PoseEstimate is available. #### Response Example ```json { "PoseEstimate": null } ``` ``` -------------------------------- ### getPoseEstimate Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/LimelightPoseEstimator.html Gets the global pose estimate based on WPILib coordinates with a blue origin. ```APIDOC ## GET /getPoseEstimate ### Description Get the global pose estimate based off WPILib coordinates, blue-origin. ### Method `GET` ### Endpoint `/getPoseEstimate` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **Optional** (object) - An optional `PoseEstimate` for the blue-origin based poses. #### Response Example ```json { "pose": { "x": 0.0, "y": 0.0, "z": 0.0, "rotation": { "quaternion": { "w": 1.0, "x": 0.0, "y": 0.0, "z": 0.0 } } }, "timestamp": 0.0 } ``` ``` -------------------------------- ### Get Limelight URL (Java) Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/LimelightUtils.html Generates the URL for a Limelight request. It takes a table name and a request URI as input and returns a URL object. This is useful for interacting with Limelight over the network. ```java public static URL getLimelightURLString(String tableName, String request) Get the URL for the limelight. Parameters: `tableName` - Limelight.limelightName `request` - URI to request from Limelight Returns: URL to request for Limelight ``` -------------------------------- ### Limelight Constructor Source: https://context7.com/yet-another-software-suite/yall/llms.txt Initializes a Limelight camera instance and connects to it via NetworkTables. It validates camera availability on the network. ```APIDOC ## Limelight Constructor ### Description Creates a new Limelight camera instance that connects to the specified camera via NetworkTables. The constructor automatically validates that the camera is available on the network before proceeding. ### Method `Limelight(String name)` ### Endpoint N/A (Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```java import limelight.Limelight; // Initialize a Limelight camera with the default name Limelight limelight = new Limelight("limelight"); // For multiple cameras, use unique names configured in the Limelight web interface Limelight frontCamera = new Limelight("limelight-front"); Limelight backCamera = new Limelight("limelight-back"); ``` ### Response #### Success Response (Instance) - **Limelight** (object) - An instance of the Limelight camera connected to the network. #### Response Example ```java Limelight limelight = new Limelight("limelight"); ``` ### Static Methods #### `isAvailable(String name)` Checks if a specific Limelight camera is available on the network. **Parameters:** - **name** (String) - The name of the Limelight camera. **Returns:** - **boolean** - `true` if the camera responds within 15 seconds, `false` otherwise. **Example:** ```java boolean isConnected = Limelight.isAvailable("limelight"); ``` ``` -------------------------------- ### Get Detector Class Index - LimelightTargetData Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/LimelightTargetData.html Gets the class index from the primary result of the neural detector pipeline. This is used to identify the class of the object detected by a neural network. ```java public int getDetectorClassIndex() ``` -------------------------------- ### Get Camera to Target Pose - LimelightTargetData Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/LimelightTargetData.html Gets the 3D pose of the camera relative to the currently tracked target. This is useful for calculating the camera's position and orientation with respect to the target in 3D space. ```java public Pose3d getCameraToTarget() ``` -------------------------------- ### Initialize Limelight Camera Instance (Java) Source: https://context7.com/yet-another-software-suite/yall/llms.txt Creates a new Limelight camera instance by connecting to the specified camera name via NetworkTables. It validates camera availability before proceeding. Supports default and custom camera names for multiple Limelight instances. ```java import limelight.Limelight; // Initialize a Limelight camera with the default name Limelight limelight = new Limelight("limelight"); // For multiple cameras, use unique names configured in the Limelight web interface Limelight frontCamera = new Limelight("limelight-front"); Limelight backCamera = new Limelight("limelight-back"); // Check if a specific Limelight is available on the network boolean isConnected = Limelight.isAvailable("limelight"); // Returns true if camera responds within 15 seconds, false otherwise ``` -------------------------------- ### Get Target to Camera Pose - LimelightTargetData Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/LimelightTargetData.html Gets the 3D pose of the currently tracked target with respect to the camera's coordinate system. This is the inverse of getCameraToTarget and useful for understanding target position relative to the camera. ```java public Pose3d getTargetToCamera() ``` -------------------------------- ### Initialize and Use LimelightPoseEstimator for Robot Localization (Java) Source: https://context7.com/yet-another-software-suite/yall/llms.txt This snippet demonstrates how to initialize and utilize the LimelightPoseEstimator for robot localization. It covers setting up the estimator, updating robot orientation, and adding vision measurements to a SwerveDrivePoseEstimator. The code filters estimates based on tag count and ambiguity before adding them. ```java import limelight.Limelight; import limelight.networktables.LimelightPoseEstimator; import limelight.networktables.LimelightPoseEstimator.EstimationMode; import limelight.networktables.LimelightPoseEstimator.BotPose; import limelight.networktables.PoseEstimate; import limelight.networktables.Orientation3d; import limelight.networktables.AngularVelocity3d; import edu.wpi.first.math.estimator.SwerveDrivePoseEstimator; import static edu.wpi.first.units.Units.DegreesPerSecond; import java.util.Optional; Limelight limelight = new Limelight("limelight"); SwerveDrivePoseEstimator poseEstimator = /* your pose estimator */; // Create a MegaTag2 pose estimator (recommended for accuracy) LimelightPoseEstimator llPoseEstimator = limelight.createPoseEstimator(EstimationMode.MEGATAG2); // In your periodic function - first update robot orientation for MegaTag2 limelight.getSettings() .withRobotOrientation(new Orientation3d( gyro.getRotation3d(), new AngularVelocity3d( DegreesPerSecond.of(gyro.getPitchVelocity()), DegreesPerSecond.of(gyro.getRollVelocity()), DegreesPerSecond.of(gyro.getYawVelocity()) ) )) .save(); // Get pose estimate (blue alliance origin - WPILib standard) Optional visionEstimate = llPoseEstimator.getPoseEstimate(); visionEstimate.ifPresent((PoseEstimate estimate) -> { // Filter based on tag count and ambiguity if (estimate.tagCount >= 2 && estimate.getMinTagAmbiguity() < 0.3) { poseEstimator.addVisionMeasurement( estimate.pose.toPose2d(), estimate.timestampSeconds ); } }); // Get alliance-specific pose (automatically uses red or blue based on DriverStation) Optional allianceEstimate = llPoseEstimator.getAlliancePoseEstimate(); allianceEstimate.ifPresent((PoseEstimate estimate) -> { System.out.println("Tag count: " + estimate.tagCount); System.out.println("Avg tag distance: " + estimate.avgTagDist + " meters"); System.out.println("Latency: " + estimate.latency + " ms"); System.out.println("Pose: " + estimate.pose); }); // Alternative: Direct BotPose enum access Optional bluePose = BotPose.BLUE_MEGATAG2.get(limelight); Optional redPose = BotPose.RED_MEGATAG2.get(limelight); // Access raw fiducial data from pose estimate visionEstimate.ifPresent((PoseEstimate estimate) -> { for (var fiducial : estimate.rawFiducials) { System.out.println("Tag ID: " + fiducial.id); System.out.println("Distance to camera: " + fiducial.distToCamera + " m"); System.out.println("Ambiguity: " + fiducial.ambiguity); } }); ``` -------------------------------- ### Get Robot to Target Pose - LimelightTargetData Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/LimelightTargetData.html Gets the 3D pose of the robot with respect to the currently tracked target's coordinate system. This is essential for robot navigation and manipulation tasks based on target location. ```java public Pose3d getRobotToTarget() ``` -------------------------------- ### Get Target to Robot Pose - LimelightTargetData Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/LimelightTargetData.html Gets the 3D pose of the currently tracked target with respect to the robot's coordinate system. This is the inverse of getRobotToTarget and provides target location relative to the robot's origin. ```java public Pose3d getTargetToRobot() ``` -------------------------------- ### Orientation3d Constructor Details Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/Orientation3d.html Details about the constructors for the Orientation3d class. ```APIDOC ## Orientation3d Constructor Details ### Description Details about the constructors for the Orientation3d class. ### Constructor 1 #### Signature `public Orientation3d(Rotation3d orientation, AngularVelocity yaw, AngularVelocity pitch, AngularVelocity roll)` #### Description Create the robot orientation based off of the given attributes. #### Parameters * **orientation** (Rotation3d) - Required - The orientation of the robot. * **yaw** (AngularVelocity) - Required - The angular velocity about the yaw/z-axis. * **pitch** (AngularVelocity) - Required - The angular velocity about the pitch/y-axis. * **roll** (AngularVelocity) - Required - The angular velocity about the roll/x-axis. ### Constructor 2 #### Signature `public Orientation3d(Rotation3d orientation, AngularVelocity3d angularVelocity)` #### Description Create the robot orientation based off the given attributes. #### Parameters * **orientation** (Rotation3d) - Required - The orientation of the robot. * **angularVelocity** (AngularVelocity3d) - Required - The angular velocity of the robot. ``` -------------------------------- ### Configure Limelight Camera Settings (Java) Source: https://context7.com/yet-another-software-suite/yall/llms.txt Provides a fluent interface for configuring Limelight camera parameters such as LED mode, camera offset, pipeline index, stream mode, AprilTag filtering, IMU settings, robot orientation, AprilTag offsets, downscaling, and crop windows. Settings are applied via NetworkTables and take effect immediately. ```java import limelight.Limelight; import limelight.networktables.LimelightSettings; import limelight.networktables.LimelightSettings.LEDMode; import limelight.networktables.LimelightSettings.StreamMode; import limelight.networktables.LimelightSettings.ImuMode; import limelight.networktables.LimelightSettings.DownscalingOverride; import limelight.networktables.Orientation3d; import limelight.networktables.AngularVelocity3d; import edu.wpi.first.math.geometry.Pose3d; import edu.wpi.first.math.geometry.Translation3d; import static edu.wpi.first.units.Units.DegreesPerSecond; import java.util.List; Limelight limelight = new Limelight("limelight"); // Configure LED mode and camera offset limelight.getSettings() .withLimelightLEDMode(LEDMode.PipelineControl) // Use pipeline's LED setting .withCameraOffset(new Pose3d()) // Camera position relative to robot center .save(); // Switch pipelines (0-9) limelight.getSettings() .withPipelineIndex(1) .save(); // Configure stream mode for driver station viewing limelight.getSettings() .withStreamMode(StreamMode.PictureInPictureMain) .save(); // Set priority AprilTag ID for pose estimation limelight.getSettings() .withPriorityTagId(4) .save(); // Filter which AprilTag IDs to track limelight.getSettings() .withArilTagIdFilter(List.of(1.0, 2.0, 3.0, 4.0)) .save(); // Configure IMU mode for MegaTag2 localization limelight.getSettings() .withImuMode(ImuMode.ExternalImu) .withImuAssistAlpha(0.001) .save(); // Set robot orientation for MegaTag2 (call in periodic loop before pose estimation) limelight.getSettings() .withRobotOrientation(new Orientation3d( gyro.getRotation3d(), new AngularVelocity3d( DegreesPerSecond.of(gyro.getPitchVelocity()), DegreesPerSecond.of(gyro.getRollVelocity()), DegreesPerSecond.of(gyro.getYawVelocity()) ) )) .save(); // Set AprilTag 3D offset point-of-interest limelight.getSettings() .withAprilTagOffset(new Translation3d(0.0, 0.0, 0.5)) // 0.5m above tag .save(); // Configure downscaling for performance tuning limelight.getSettings() .withFiducialDownscalingOverride(DownscalingOverride.DoubleDownscale) .save(); // Set crop window (-1 to 1 for x and y) limelight.getSettings() .withCropWindow(-0.5, 0.5, -0.5, 0.5) .save(); ``` -------------------------------- ### Get Barcode Family Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/target/Barcode.html Retrieves the family type of the barcode. ```APIDOC ## GET /barcode/family ### Description Gets the family type of the barcode. ### Method GET ### Endpoint /barcode/family ### Response #### Success Response (200) - **family** (String) - The family type of the barcode. #### Response Example { "family": "QR_CODE" } ``` -------------------------------- ### Configure Limelight Settings and Pose Estimator (Python) Source: https://context7.com/yet-another-software-suite/yall/llms.txt Utilize the Python API for Limelight integration, providing equivalent functionality to the Java API. This includes initializing Limelight, configuring settings like LED mode and pipeline index, and creating a pose estimator for advanced tracking. ```python from yall.limelight import ( Limelight, LimelightSettings, LimelightPoseEstimator, EstimationMode, BotPose, PoseEstimate, ) from yall.networktables.geometry import Orientation3d, AngularVelocity3d from wpimath import geometry, units # Initialize Limelight limelight = Limelight("limelight") # Configure settings settings = limelight.getSettings() settings.withLimelightLEDMode(LimelightSettings.LEDMode.PipelineControl) settings.withPipelineIndex(0) settings.withImuMode(LimelightSettings.ImuMode.ExternalImu) # Set robot orientation for MegaTag2 orientation = Orientation3d( gyro.getRotation3d(), AngularVelocity3d( units.degrees_per_second(gyro.getPitchVelocity()), units.degrees_per_second(gyro.getRollVelocity()), units.degrees_per_second(gyro.getYawVelocity()) ) ) settings.withRobotOrientation(orientation) # Create pose estimator pose_estimator = limelight.createPoseEstimator(EstimationMode.MEGATAG2) ``` -------------------------------- ### Vision Pose Estimation with MegaTag2 in Java Source: https://github.com/yet-another-software-suite/yall/blob/main/README.md This snippet shows how to initialize Limelight, set robot orientation for MegaTag2, and retrieve/add vision pose estimates to a pose estimator. It requires the Limelight library and a gyro sensor for orientation data. ```java Limelight limelight = new Limelight("limelight"); // Required for megatag2 in periodic() function before fetching pose. limelight.getSettings() .withRobotOrientation(new Orientation3d(gyro.getRotation3d(), new AngularVelocity3d(DegreesPerSecond.of(gyro.getPitchVelocity()), DegreesPerSecond.of(gyro.getRollVelocity()), DegreesPerSecond.of(gyro.getYawVelocity())))) .save(); // Get MegaTag2 pose Optional visionEstimate = poseEstimator.getPoseEstimate(); // If the pose is present visionEstimate.ifPresent((PoseEstimate poseEstimate) -> { // Add it to the pose estimator. poseEstimator.addVisionMeasurement(poseEstimate.pose.toPose2d(), poseEstimate.timestampSeconds); }); ``` -------------------------------- ### getAlliancePoseEstimate Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/LimelightPoseEstimator.html Gets the PoseEstimate corresponding to the current alliance color. Requires DriverStation to be connected or simulation GUI to be in a connected mode. ```APIDOC ## GET /getAlliancePoseEstimate ### Description Get the `PoseEstimate` corresponding with your alliance color. Alliance comes from DriverStation. If simulation, then the sim GUI must not be in "disconnected" mode. ### Method `GET` ### Endpoint `/getAlliancePoseEstimate` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **Optional** (object) - An optional `PoseEstimate` for the current alliance color. #### Response Example ```json { "pose": { "x": 0.0, "y": 0.0, "z": 0.0, "rotation": { "quaternion": { "w": 1.0, "x": 0.0, "y": 0.0, "z": 0.0 } } }, "timestamp": 0.0 } ``` ``` -------------------------------- ### PoseEstimate Methods Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/PoseEstimate.html This section details the available methods for interacting with the PoseEstimate object. ```APIDOC ## PoseEstimate Methods ### refresh * **Method**: `refresh()` * **Description**: Refresh the `PoseEstimate` object. * **Returns**: `PoseEstimate` - The refreshed PoseEstimate object for chaining. ### getPoseEstimate * **Method**: `getPoseEstimate()` * **Description**: Retrieves the current pose estimate. * **Returns**: `Optional` - An Optional containing the PoseEstimate object if data is available, otherwise an empty Optional. ### getMinTagAmbiguity * **Method**: `getMinTagAmbiguity()` * **Description**: Get the minimum ambiguity from seen AprilTag's. * **Returns**: `double` - Min ambiguity from observed tags. ### getMaxTagAmbiguity * **Method**: `getMaxTagAmbiguity()` * **Description**: Get the maximum ambiguity from seen AprilTag's. * **Returns**: `double` - Max ambiguity from observed tags. Returns 1 if none. ``` -------------------------------- ### Get Current Pipeline Type (Java) Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/LimelightPipelineData.html Retrieves the type of the current pipeline. This method returns a string that identifies the pipeline, such as 'retro' or 'apriltag'. ```java public String getCurrentPipelineType() ``` -------------------------------- ### LimelightUtils Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/index-all.html Utility classes for converting WPILib data to LimelightLib expected values. ```APIDOC ## Class: LimelightUtils ### Description Utility classes to convert WPILib data to LimelightLib expected values. ### Endpoint N/A (Class definition) ### Parameters N/A ### Request Example N/A ### Response N/A ## Constructor: LimelightUtils() ### Description Constructs a LimelightUtils object. ### Method Constructor ### Endpoint N/A (Constructor) ### Parameters N/A ### Request Example N/A ### Response N/A ## Static Method: orientation3dToArray(Orientation3d) ### Description Converts an Orientation3d object to a 6-length array of [yaw, yaw rate, pitch, pitch rate, roll, roll rate] in Degrees. ### Method Static ### Endpoint N/A (Static method) ### Parameters - **orientation3d** (Orientation3d) - The Orientation3d object to convert. ### Request Example N/A ### Response - **array** (double[]) - A 6-element array representing orientation and angular velocity. ``` -------------------------------- ### Get Pose in Target Space (2D) Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/target/AprilTagFiducial.html Retrieves the estimated 2D pose of the camera relative to the target. This method is part of the AprilTagFiducial class and returns a Pose2d object. ```Java public Pose2d getCameraPose_TargetSpace2D() ``` -------------------------------- ### LimelightSettings Configuration API Source: https://context7.com/yet-another-software-suite/yall/llms.txt Provides a fluent interface for configuring Limelight camera parameters via NetworkTables. Settings are applied immediately. ```APIDOC ## LimelightSettings Configuration API ### Description The settings API provides a fluent interface for configuring Limelight camera parameters. All settings are applied via NetworkTables and take effect immediately on the camera. ### Method `limelight.getSettings()` returns a `LimelightSettings` object. ### Endpoint N/A (Configuration via NetworkTables) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Configuration Methods (Chained calls on `LimelightSettings` object, followed by `.save()`) - **`withLimelightLEDMode(LEDMode mode)`**: Configures the Limelight's LED mode. - **`LEDMode`**: `PipelineControl`, `Off`, `Blink`, `On` - **`withCameraOffset(Pose3d offset)`**: Sets the camera's position relative to the robot's center. - **`withPipelineIndex(int index)`**: Switches to a specific pipeline (0-9). - **`withStreamMode(StreamMode mode)`**: Configures the stream mode for driver station viewing. - **`StreamMode`**: `Standard`, `PictureInPictureMain`, `PictureInPictureSecondary`, `Disabled` - **`withPriorityTagId(int id)`**: Sets the priority AprilTag ID for pose estimation. - **`withArilTagIdFilter(List ids)`**: Filters which AprilTag IDs to track. - **`withImuMode(ImuMode mode)`**: Configures the IMU mode for localization. - **`ImuMode`**: `None`, `Standard`, `ExternalImu` - **`withImuAssistAlpha(double alpha)`**: Sets the alpha value for IMU assist in MegaTag2 localization. - **`withRobotOrientation(Orientation3d orientation)`**: Sets the robot's orientation for MegaTag2 localization. Should be called in the periodic loop before pose estimation. - **`withAprilTagOffset(Translation3d offset)`**: Sets the 3D offset point-of-interest for AprilTag detection. - **`withFiducialDownscalingOverride(DownscalingOverride override)`**: Configures downscaling for performance tuning. - **`DownscalingOverride`**: `Disabled`, `HalfDownscale`, `QuarterDownscale`, `DoubleDownscale` - **`withCropWindow(double xMin, double xMax, double yMin, double yMax)`**: Sets the crop window for the camera feed. Values range from -1 to 1 for x and y. ### Request Example ```java import limelight.Limelight; import limelight.networktables.LimelightSettings; import limelight.networktables.LimelightSettings.LEDMode; import limelight.networktables.LimelightSettings.StreamMode; import limelight.networktables.LimelightSettings.ImuMode; import limelight.networktables.LimelightSettings.DownscalingOverride; import limelight.networktables.Orientation3d; import limelight.networktables.AngularVelocity3d; import edu.wpi.first.math.geometry.Pose3d; import edu.wpi.first.math.geometry.Translation3d; import static edu.wpi.first.units.Units.DegreesPerSecond; import java.util.List; Limelight limelight = new Limelight("limelight"); // Configure LED mode and camera offset limelight.getSettings() .withLimelightLEDMode(LEDMode.PipelineControl) // Use pipeline's LED setting .withCameraOffset(new Pose3d()) // Camera position relative to robot center .save(); // Switch pipelines (0-9) limelight.getSettings() .withPipelineIndex(1) .save(); // Configure stream mode for driver station viewing limelight.getSettings() .withStreamMode(StreamMode.PictureInPictureMain) .save(); // Set priority AprilTag ID for pose estimation limelight.getSettings() .withPriorityTagId(4) .save(); // Filter which AprilTag IDs to track limelight.getSettings() .withArilTagIdFilter(List.of(1.0, 2.0, 3.0, 4.0)) .save(); // Configure IMU mode for MegaTag2 localization limelight.getSettings() .withImuMode(ImuMode.ExternalImu) .withImuAssistAlpha(0.001) .save(); // Set robot orientation for MegaTag2 (call in periodic loop before pose estimation) // Assuming 'gyro' is an instance of your IMU sensor // limelight.getSettings() // .withRobotOrientation(new Orientation3d( // gyro.getRotation3d(), // new AngularVelocity3d( // DegreesPerSecond.of(gyro.getPitchVelocity()), // DegreesPerSecond.of(gyro.getRollVelocity()), // DegreesPerSecond.of(gyro.getYawVelocity()) // ) // )) // .save(); // Set AprilTag 3D offset point-of-interest limelight.getSettings() .withAprilTagOffset(new Translation3d(0.0, 0.0, 0.5)) // 0.5m above tag .save(); // Configure downscaling for performance tuning limelight.getSettings() .withFiducialDownscalingOverride(DownscalingOverride.DoubleDownscale) .save(); // Set crop window (-1 to 1 for x and y) limelight.getSettings() .withCropWindow(-0.5, 0.5, -0.5, 0.5) .save(); ``` ### Response #### Success Response (Configuration Applied) - **void** - The `save()` method returns void, indicating the settings have been applied. #### Response Example (No direct response body, settings are applied to the Limelight camera via NetworkTables.) ``` -------------------------------- ### Get Pose in Target Space (3D) Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/target/AprilTagFiducial.html Retrieves the estimated 3D pose of the camera relative to the target. This method is part of the AprilTagFiducial class and returns a Pose3d object. ```Java public Pose3d getCameraPose_TargetSpace() ``` -------------------------------- ### LimelightSettings Constructor Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/LimelightSettings.html Initializes a LimelightSettings object with a specified Limelight camera. ```APIDOC ## LimelightSettings Constructor ### Description Creates a LimelightSettings object with all configurable features of a Limelight camera. ### Method `public LimelightSettings(Limelight camera)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```json { "camera": "Limelight" } ``` ### Response #### Success Response (200) This constructor does not return a value, it initializes the object. #### Response Example N/A ``` -------------------------------- ### Get 2D Bot Pose Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/LimelightResults.html Retrieves the 2D pose of the robot, optionally filtered by alliance color. ```APIDOC ## GET /bot/pose2d ### Description Retrieves the 2D pose of the robot. This can be filtered by specifying the alliance color. ### Method GET ### Endpoint /bot/pose2d ### Parameters #### Query Parameters - **alliance** (DriverStation.Alliance) - Optional - The alliance color to filter the pose by. ### Response #### Success Response (200) - **pose2d** (Pose2d) - The 2D pose of the robot. #### Response Example ```json { "pose2d": { "translation": { "x": 0.0, "y": 0.0 }, "rotation": { "degrees": 0.0 } } } ``` ``` -------------------------------- ### LimelightPipelineData Constructor Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/LimelightPipelineData.html Constructs a LimelightPipelineData object associated with a specific Limelight camera. ```APIDOC ## LimelightPipelineData Constructor ### Description Constructs data for pipelines associated with a Limelight camera. ### Method CONSTRUCTOR ### Endpoint N/A (Class Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```java LimelightPipelineData pipelineData = new LimelightPipelineData(limelightCamera); ``` ### Response #### Success Response (Constructor) N/A (Constructor does not return a value in the traditional sense, but initializes an object). #### Response Example N/A ``` -------------------------------- ### Get 3D Bot Pose Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/LimelightResults.html Retrieves the 3D pose of the robot, optionally filtered by alliance color. ```APIDOC ## GET /bot/pose3d ### Description Retrieves the 3D pose of the robot. This can be filtered by specifying the alliance color. ### Method GET ### Endpoint /bot/pose3d ### Parameters #### Query Parameters - **alliance** (DriverStation.Alliance) - Optional - The alliance color to filter the pose by. ### Response #### Success Response (200) - **pose3d** (Pose3d) - The 3D pose of the robot. #### Response Example ```json { "pose3d": { "translation": { "x": 0.0, "y": 0.0, "z": 0.0 }, "rotation": { "quaternion": { "w": 1.0, "x": 0.0, "y": 0.0, "z": 0.0 } } } } ``` ``` -------------------------------- ### Initialize LimelightSettings Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/LimelightSettings.html Creates a LimelightSettings object to configure a Limelight camera. This constructor fetches initial settings from the Limelight, though they are not programmatically accessible. ```java LimelightSettings settings = new LimelightSettings(limelightCamera); ``` -------------------------------- ### Get Current Pipeline Index (Java) Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/LimelightPipelineData.html Retrieves the active pipeline index. This method returns a double representing the current pipeline index, which is expected to be between 0 and 9. ```java public double getCurrentPipelineIndex() ``` -------------------------------- ### LimelightSettings Configuration Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/index-all.html Methods for configuring various aspects of the Limelight camera settings. ```APIDOC ## POST /limelight/settings/aprilTagOffset ### Description Set the offset from the AprilTag that is of interest. ### Method POST ### Endpoint /limelight/settings/aprilTagOffset ### Parameters #### Query Parameters - **x** (double) - Required - The x-component of the translation. - **y** (double) - Required - The y-component of the translation. - **z** (double) - Required - The z-component of the translation. ### Request Example ``` POST /limelight/settings/aprilTagOffset?x=0.1&y=0.2&z=0.3 ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "AprilTag offset set successfully." } ``` ## POST /limelight/settings/aprilTagIdFilter ### Description Set the [`Limelight`](limelight/Limelight.html "class in limelight") AprilTagID filter/override of which to track. ### Method POST ### Endpoint /limelight/settings/aprilTagIdFilter ### Parameters #### Query Parameters - **tagIds** (List) - Required - A list of AprilTag IDs to filter. ### Request Example ``` POST /limelight/settings/aprilTagIdFilter?tagIds=1,2,3 ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "AprilTag ID filter set successfully." } ``` ## POST /limelight/settings/cameraOffset ### Description Set the [`Limelight`](limelight/Limelight.html "class in limelight") offset. ### Method POST ### Endpoint /limelight/settings/cameraOffset ### Parameters #### Query Parameters - **x** (double) - Required - The x-component of the camera's pose. - **y** (double) - Required - The y-component of the camera's pose. - **z** (double) - Required - The z-component of the camera's pose. - **roll** (double) - Required - The roll of the camera's pose. - **pitch** (double) - Required - The pitch of the camera's pose. - **yaw** (double) - Required - The yaw of the camera's pose. ### Request Example ``` POST /limelight/settings/cameraOffset?x=0.1&y=0.2&z=0.3&roll=0&pitch=0&yaw=0 ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Camera offset set successfully." } ``` ## POST /limelight/settings/cropWindow ### Description Sets the crop window for the camera. ### Method POST ### Endpoint /limelight/settings/cropWindow ### Parameters #### Query Parameters - **xMin** (double) - Required - The minimum x-coordinate of the crop window. - **yMin** (double) - Required - The minimum y-coordinate of the crop window. - **xMax** (double) - Required - The maximum x-coordinate of the crop window. - **yMax** (double) - Required - The maximum y-coordinate of the crop window. ### Request Example ``` POST /limelight/settings/cropWindow?xMin=0.1&yMin=0.1&xMax=0.9&yMax=0.9 ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Crop window set successfully." } ``` ## POST /limelight/settings/fiducialDownscalingOverride ### Description Sets the downscaling factor for AprilTag detection. ### Method POST ### Endpoint /limelight/settings/fiducialDownscalingOverride ### Parameters #### Query Parameters - **override** (LimelightSettings.DownscalingOverride) - Required - The downscaling override setting. ### Request Example ``` POST /limelight/settings/fiducialDownscalingOverride?override=2X ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Fiducial downscaling override set successfully." } ``` ## POST /limelight/settings/imuMode ### Description Set the IMU Mode based on the [`LimelightSettings.ImuMode`](limelight/networktables/LimelightSettings.ImuMode.html "enum class in limelight.networktables") enum. ### Method POST ### Endpoint /limelight/settings/imuMode ### Parameters #### Query Parameters - **mode** (LimelightSettings.ImuMode) - Required - The IMU mode to set. ### Request Example ``` POST /limelight/settings/imuMode?mode=ROBOT_VISION ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "IMU mode set successfully." } ``` ## POST /limelight/settings/ledMode ### Description Set the [`Limelight`](limelight/Limelight.html "class in limelight") [`LimelightSettings.LEDMode`](limelight/networktables/LimelightSettings.LEDMode.html "enum class in limelight.networktables"). ### Method POST ### Endpoint /limelight/settings/ledMode ### Parameters #### Query Parameters - **mode** (LimelightSettings.LEDMode) - Required - The LED mode to set. ### Request Example ``` POST /limelight/settings/ledMode?mode=ON ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Limelight LED mode set successfully." } ``` ## POST /limelight/settings/pipelineIndex ### Description Set the current pipeline index for the [`Limelight`](limelight/Limelight.html "class in limelight"). ### Method POST ### Endpoint /limelight/settings/pipelineIndex ### Parameters #### Query Parameters - **index** (int) - Required - The pipeline index to set. ### Request Example ``` POST /limelight/settings/pipelineIndex?index=0 ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Pipeline index set successfully." } ``` ## POST /limelight/settings/priorityTagId ### Description Set the priority AprilTag ID. ### Method POST ### Endpoint /limelight/settings/priorityTagId ### Parameters #### Query Parameters - **id** (int) - Required - The priority AprilTag ID to set. ### Request Example ``` POST /limelight/settings/priorityTagId?id=5 ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message. #### Response Example ```json { "message": "Priority tag ID set successfully." } ``` ``` -------------------------------- ### Limelight NetworkTables Package Overview Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/package-summary.html Provides an overview of the Limelight NetworkTables package, its purpose, and related packages. ```APIDOC ## Package: limelight.networktables ### Description All Structures and utilities relating to Limelight NetworkTable data. ### Related Packages - **limelight**: Primary Limelight package containing LimelightLib - **limelight.networktables.target**: Target data structures mapped to NetworkTables data. - **limelight.results**: Results package for detections and fiducials(AprilTags) ### Classes and Interfaces - **AngularVelocity3d**: Angular velocity 3d helper class. - **LimelightData**: Data retrieval class for `Limelight`. - **LimelightPipelineData**: Pipeline data for `Limelight`. - **LimelightPoseEstimator**: Pose estimator for `Limelight`. - **LimelightPoseEstimator.BotPose**: BotPose enum for easier decoding. - **LimelightResults**: `Limelight` Results object, parsed from a `Limelight`'s JSON limelight.results output. - **LimelightSettings**: Settings class to apply configurable options to the `Limelight`. - **LimelightSettings.DownscalingOverride**: Downscaling Override Enum for `Limelight`. - **LimelightSettings.ImuMode**: IMU Mode Enum for the `Limelight`. - **LimelightSettings.LEDMode**: LED Mode for the `Limelight`. - **LimelightSettings.StreamMode**: Stream mode for the `Limelight`. - **LimelightTargetData**: Target data structure. - **LimelightUtils**: Utility classes to convert WPILib data to LimelightLib expected values. - **Orientation3d**: Orientation3d of the robot for `Limelight`. - **PoseEstimate**: Represents a 3D Pose Estimate. ``` -------------------------------- ### Get Target Pose in Camera Space (2D) Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/target/AprilTagFiducial.html Retrieves the estimated 2D pose of the target relative to the camera. This method is part of the AprilTagFiducial class and returns a Pose2d object. ```Java public Pose2d getTargetPose_CameraSpace2D() ``` -------------------------------- ### Get Robot Pose in Target Space (2D) Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/target/AprilTagFiducial.html Retrieves the estimated 2D pose of the robot relative to the target. This method is part of the AprilTagFiducial class and returns a Pose2d object. ```Java public Pose2d getRobotPose_TargetSpace2D() ``` -------------------------------- ### Limelight Methods Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/Limelight.html Details the methods available in the Limelight class for interacting with the camera and its data. ```APIDOC ## Methods ### `flush()` - **Description**: Flush the NetworkTable data to server. - **Return Type**: `void` ### `getData()` - **Description**: Get the `LimelightData` object for the Limelight. - **Return Type**: `LimelightData` ### `getLatestResults()` - **Description**: Gets the latest JSON `LimelightResults` output and returns a LimelightResults object. - **Return Type**: `Optional` ### `getNTTable()` - **Description**: Get the `NetworkTable` for this limelight. - **Return Type**: `NetworkTable` ### `createPoseEstimator(boolean megatag2)` - **Description**: Create a `LimelightPoseEstimator` for the Limelight. - **Parameters**: - `megatag2` (boolean) - Flag to indicate if using megatag2. - **Return Type**: `LimelightPoseEstimator` ### `getSettings()` - **Description**: Get the `LimelightSettings` preparatory to changing settings. - **Return Type**: `LimelightSettings` ### `isAvailable(String limelightName)` - **Description**: Verify limelight name exists as a table in NT. - **Parameters**: - `limelightName` (String) - The name of the limelight to check. - **Return Type**: `boolean` ### `snapshot(String snapshotname)` - **Description**: Asynchronously take a snapshot in limelight. - **Parameters**: - `snapshotname` (String) - The name for the snapshot. - **Return Type**: `void` ``` -------------------------------- ### Get Robot Pose in Field Space (2D) Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/target/AprilTagFiducial.html Retrieves the estimated 2D pose of the robot relative to the field. This method is part of the AprilTagFiducial class and returns a Pose2d object. ```Java public Pose2d getRobotPose_FieldSpace2D() ``` -------------------------------- ### Get Target Pose in Robot Space (3D) Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/target/AprilTagFiducial.html Retrieves the estimated 3D pose of the target relative to the robot. This method is part of the AprilTagFiducial class and returns a Pose3d object. ```Java public Pose3d getTargetPose_RobotSpace() ``` -------------------------------- ### LimelightUtils Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/index-all.html Utility methods for Limelight, including converting Pose2d and Pose3d objects to arrays. ```APIDOC ## Class: LimelightUtils ### Description Utility class providing helper methods for Limelight operations. ### Endpoint limelight/networktables/LimelightUtils.html ### Static Methods - **pose2dToArray(Pose2d)** - Converts a [`Pose2d`](https://github.wpilib.org/allwpilib/docs/release/java/edu/wpi/first/math/geometry/Pose2d.html "class or interface in edu.wpi.first.math.geometry") object to an array of doubles in the format [x, y, z, roll, pitch, yaw]. - **pose3dToArray(Pose3d)** - Converts a [`Pose3d`](https://github.wpilib.org/allwpilib/docs/release/java/edu/wpi/first/math/geometry/Pose3d.html "class or interface in edu.wpi.first.math.geometry") object to an array of doubles in the format [x, y, z, roll, pitch, yaw]. ``` -------------------------------- ### Get Target Pose in Camera Space (3D) Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/limelight/networktables/target/AprilTagFiducial.html Retrieves the estimated 3D pose of the target relative to the camera. This method is part of the AprilTagFiducial class and returns a Pose3d object. ```Java public Pose3d getTargetPose_CameraSpace() ``` -------------------------------- ### Limelight Settings Source: https://github.com/yet-another-software-suite/yall/blob/main/docs/index-all.html Configuration options for Limelight stream mode and IMU synchronization. ```APIDOC ## Limelight Settings API ### Description This API group provides access to Limelight settings, including stream modes and IMU synchronization options. ### Stream Modes - **Standard**: Side by side stream mode. ### IMU Modes - **SyncInternalImu**: Use external IMU yaw submitted via `LimelightSettings.withRobotOrientation(Orientation3d)` for MT2 localization. ```