> 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
