> For the complete documentation index, see [llms.txt](https://yall.yassrobotics.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yall.yassrobotics.com/api-reference/java-reference/limelight.md).

# Limelight

**Package:** `limelight`

`Limelight` is the entry point for the library — one instance per physical camera, bound to that camera's NetworkTables table (`/<name>`). Construction verifies the table exists (except in simulation) and creates the associated `LimelightData` and `LimelightSettings` objects.

***

## Constructor

```java
Limelight(String name)
```

| Parameter | Description                                                                 |
| --------- | --------------------------------------------------------------------------- |
| `name`    | NetworkTables name of the camera, e.g. `"limelight"` or `"limelight-front"` |

***

## Fields

| Field           | Type     | Description                     |
| --------------- | -------- | ------------------------------- |
| `limelightName` | `String` | Name passed to the constructor. |

***

## Methods

| Method                                        | Returns                      | Description                                                                                                                                                                                      |
| --------------------------------------------- | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `getSettings()`                               | `LimelightSettings`          | Chainable object for `.withXXXX()` configuration calls. See [LimelightSettings](/api-reference/java-reference/networktables/limelight-settings.md).                                              |
| `getData()`                                   | `LimelightData`              | Read-only NetworkTables data: raw fiducials, raw detections, barcodes, Python I/O. See [LimelightData](/api-reference/java-reference/networktables/limelight-data.md).                           |
| `createPoseEstimator(EstimationMode)`         | `LimelightPoseEstimator`     | Creates a MegaTag1 or MegaTag2 pose estimator bound to this camera. See [LimelightPoseEstimator](/api-reference/java-reference/networktables/limelight-pose-estimator.md).                       |
| `getLatestResults()`                          | `Optional<LimelightResults>` | Parses the latest `limelight.results` JSON blob. Empty if the Limelight isn't publishing JSON over NT. See [LimelightResults](/api-reference/java-reference/networktables/limelight-results.md). |
| `getNTTable()`                                | `NetworkTable`               | The underlying `NetworkTable` for this camera.                                                                                                                                                   |
| `flush()`                                     | `void`                       | Flushes the default `NetworkTableInstance` immediately.                                                                                                                                          |
| `rewindCapture(double durationSeconds)`       | `void`                       | Triggers a rewind buffer capture (max 165s, rate-limited on the Limelight). Requires supported hardware.                                                                                         |
| `snapshot(String snapshotname)`               | `void`                       | Asynchronously requests an HTTP snapshot capture (`capturesnapshot`) named `snapshotname`.                                                                                                       |
| `static isAvailable(String limelightName)`    | `boolean`                    | Polls NetworkTables (up to 2s) for a `getpipe` key under the given table name. Raises a WPILib `Alert` and returns `false` if not found.                                                         |
| `static setupPortForwardingUSB(int usbIndex)` | `void`                       | Forwards ports `5800-5809 + usbIndex*10` to `172.29.<usbIndex>.1:5800-5809` for USB-connected LL3A/3G web UI access.                                                                             |

***

## Notes

* `isAvailable` is meant to run once, at robot construction — not in a periodic loop. Use `getData().targetData.getTargetStatus()` for per-iteration 2D target validity, or `PoseEstimate.hasData` for 3D pose validity.
* `snapshot()` runs the HTTP request on a separate thread via `CompletableFuture` so it never blocks the robot loop.

## See Also

* [LimelightSettings](/api-reference/java-reference/networktables/limelight-settings.md)
* [LimelightPoseEstimator](/api-reference/java-reference/networktables/limelight-pose-estimator.md)
* [LimelightData](/api-reference/java-reference/networktables/limelight-data.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://yall.yassrobotics.com/api-reference/java-reference/limelight.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
