> 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/how-to-guides/how-do-i-mount-a-limelight-on-a-moving-mechanism.md).

# How do I mount a Limelight on a moving mechanism?

`withCameraOffset` isn't limited to a fixed, one-time value. Call it every periodic loop with a pose computed from your mechanism's current position when the camera itself moves relative to robot center.

## Example: camera mounted on a rotating turret

Adapted from YALL's `TurretSubsystem` example ([LocalizationExamples](https://github.com/BroncBotz3481/YALL/tree/main/LocalizationExamples)):

```java
@Override
public void periodic() {
    limelight.getSettings()
             .withRobotOrientation(new Orientation3d(new Rotation3d(swerveDrive.getOdometryHeading()),
                                                      new AngularVelocity3d(DegreesPerSecond.of(0),
                                                                            DegreesPerSecond.of(0),
                                                                            DegreesPerSecond.of(0))))
             .withCameraOffset(cameraOffsetFromRobotCenter.rotateAround(
                     turretPivotCenterFromCamera,
                     new Rotation3d(0, 0, turret.getAngle().in(Radians))))
             .save();
}
```

`cameraOffsetFromRobotCenter` is the camera's pose when the turret sits at its zero angle. `rotateAround` re-derives the camera's *current* offset every loop by rotating that fixed pose around the turret's pivot point by the turret's live angle. Without this, MegaTag pose estimates silently assume the camera never moved and drift as the turret rotates.

## Checklist

* Measure `cameraOffsetFromRobotCenter` and the turret pivot point once, physically, at turret-zero.
* Call `withCameraOffset` with the *recomputed* pose every loop, not just once at startup.
* Still submit `withRobotOrientation` every loop for MegaTag2; the two settings are independent (robot heading vs. camera-to-robot offset).

## See Also

* [AprilTag Pose Estimation tutorial](/documentation/tutorials/apriltag-pose-estimation.md)
* [How do I choose between MegaTag1 and MegaTag2?](/documentation/how-to-guides/how-do-i-choose-megatag1-vs-megatag2.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/documentation/how-to-guides/how-do-i-mount-a-limelight-on-a-moving-mechanism.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.
