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