> 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/documentation/tutorials/basic-setup.md).

# Basic Setup

This tutorial creates a `Limelight`, configures it, and reads its 2D target data: the minimum setup for any pipeline type.

## 1. Install YALL

See [How do I install YALL?](/documentation/how-to-guides/how-do-i-install-yall.md) if you haven't added the vendordep yet.

## 2. Create the Limelight object

Create one `Limelight` per physical camera, named after its NetworkTables table (the name shown in the Limelight web UI, usually `limelight`):

```java
import limelight.Limelight;

Limelight limelight = new Limelight("limelight");
```

{% hint style="info" %}
Construction checks that the camera's NT table exists (skipped in simulation) and raises a WPILib `Alert` if it doesn't. Do this once, in your subsystem constructor, not in `periodic()`.
{% endhint %}

## 3. Configure it

`getSettings()` returns a chainable configuration object. Every `.withXXXX()` call applies immediately and returns `this`:

```java
import limelight.networktables.LimelightSettings.LEDMode;
import edu.wpi.first.math.geometry.Pose3d;

limelight.getSettings()
         .withLimelightLEDMode(LEDMode.PipelineControl)
         .withCameraOffset(Pose3d.kZero)
         .save();
```

`withCameraOffset` sets where the camera physically sits relative to robot center. Get this right, since MegaTag pose estimation is only as accurate as this offset. See [LimelightSettings & Pipelines](/documentation/understanding/limelight-settings-and-pipelines.md) for the full option list.

## 4. Read 2D target data

For simple aiming (turn-to-target, distance-to-target), `getData().targetData` gives you crosshair-relative offsets without any pose estimation:

```java
if (limelight.getData().targetData.getTargetStatus()) {
    double tx = limelight.getData().targetData.getHorizontalOffset();
    double ty = limelight.getData().targetData.getVerticalOffset();
    // turn toward tx, adjust range using ty
}
```

Always check `getTargetStatus()` before trusting `tx`/`ty`, since they hold stale values when no target is visible.

## Next steps

* [AprilTag Pose Estimation](/documentation/tutorials/apriltag-pose-estimation.md): fuse MegaTag2 into your robot's pose estimator.
* [Object Detection](/documentation/tutorials/object-detection.md): read neural classifier/detector results.
* [Simulating a Limelight](/documentation/tutorials/simulating-a-limelight.md): exercise this same code in desktop simulation.
* [How do I choose between MegaTag1 and MegaTag2?](/documentation/how-to-guides/how-do-i-choose-megatag1-vs-megatag2.md)
* [Tuning Workflow Overview](/documentation/tuning/tuning-workflow-overview.md): once basic setup works, this is the recommended order for getting accurate, reliable results out of whichever pipeline you're using.


---

# 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/documentation/tutorials/basic-setup.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.
