> For the complete documentation index, see [llms.txt](https://yams.yassrobotics.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yams.yassrobotics.com/api-reference/java-reference/config/mechanism-position-config.md). Agents can also search and read this documentation through its [MCP server](https://yams.yassrobotics.com/~gitbook/mcp).

# MechanismPositionConfig

**Package:** `yams.core.mechanisms.config`\
**Javadoc:** [`MechanismPositionConfig`](https://javadocs.yassrobotics.com/yams/yams/core/mechanisms/config/MechanismPositionConfig.html)

`MechanismPositionConfig` places a mechanism on the robot: where it is mounted, how it is turned there, the plane it moves in, and the mechanism it is mounted on, if any. Each mechanism's `getPose3d()` is worked out from it, to publish as a component of an AdvantageScope robot model. It also sizes and places the mechanism's `Mechanism2d` in simulation. All builder methods return the `MechanismPositionConfig` for chaining.

Give it to a mechanism with `withMechanismPositionConfig(...)` on [ArmConfig](https://yams.yassrobotics.com/api-reference/java-reference/config/arm-config.md), [ElevatorConfig](https://yams.yassrobotics.com/api-reference/java-reference/config/elevator-config.md), [PivotConfig](https://yams.yassrobotics.com/api-reference/java-reference/config/pivot-config.md), [FlyWheelConfig](https://yams.yassrobotics.com/api-reference/java-reference/config/flywheel-config.md) or [DifferentialMechanismConfig](https://yams.yassrobotics.com/api-reference/java-reference/config/differential-mechanism-config.md).

See also: [How do I show my mechanisms on a 3D robot model?](https://yams.yassrobotics.com/documentation/how-to-simulation-and-logging/how-do-i-show-my-mechanisms-on-a-3d-robot-model)

***

## Coordinates

Positions are in meters from the robot's origin, which AdvantageScope puts at the center of the robot, on the floor: +X forward, +Y left and +Z up.

A part that turns, such as an arm, a pivot or a flywheel, turns about the axis normal to its movement plane:

| Plane          | At 0, the part points | A positive angle turns it | Example                           |
| -------------- | --------------------- | ------------------------- | --------------------------------- |
| `XZ` (default) | +X, forward           | Toward +Z, up             | An arm that swings over the front |
| `YZ`           | +Y, left              | Toward +Z, up             | An arm that swings over the side  |
| `XY`           | +X, forward           | Toward +Y, left           | A turret. A `Pivot`'s default     |

A part that slides, such as an elevator's carriage, moves along its angle in the movement plane: 0 along +X (+Y in the YZ plane), 90° along +Z (+Y in the XY plane).

***

## Constructor

```java
MechanismPositionConfig()
```

The movement plane is XZ. A `PivotConfig` gives its pivot an XY plane unless you give it your own `MechanismPositionConfig`.

***

## Builder methods

| Method                                                 | Parameters                                | Description                                                                                                                                                |
| ------------------------------------------------------ | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `withRelativePosition(Translation3d robotToMechanism)` | `robotToMechanism`: where it is mounted   | Where the mechanism is mounted, from the robot, or from its parent: an arm's or pivot's axis, an elevator's carriage at zero height, or a flywheel's axle. |
| `withRelativePosition(Transform3d robotToMechanism)`   | `robotToMechanism`: where, and how turned | Also sets how the mechanism is turned where it is mounted, such as an arm on the side of the robot facing left.                                            |
| `withParent(Supplier<Pose3d> parentPose)`              | `parentPose`: the pose it is mounted on   | Mounts the mechanism on another, such as an arm on `elevator::getPose3d`, so it moves with it. Its relative position is then from the parent's pose.       |
| `withMovementPlane(Plane plane)`                       | `plane`: `XZ`, `YZ` or `XY`               | The plane the mechanism moves in. Default `XZ`.                                                                                                            |
| `withMaxRobotLength(Distance robotLength)`             | `robotLength`: the robot's length         | Sizes the `Mechanism2d` window. Defaults to twice the mechanism's length.                                                                                  |
| `withMaxRobotHeight(Distance robotHeight)`             | `robotHeight`: the robot's height         | Sizes the `Mechanism2d` window. Defaults to twice the mechanism's length.                                                                                  |

***

## Poses

These do the math for each mechanism's `getPose3d()`, and can place a part YAMS has no mechanism for.

| Method                                              | Returns      | Description                                                                                                          |
| --------------------------------------------------- | ------------ | -------------------------------------------------------------------------------------------------------------------- |
| `getMountPose()`                                    | `Pose3d`     | Where the mechanism is mounted: its parent's pose, or the robot's origin, moved and turned by its relative position. |
| `getRotatedPose(Angle angle)`                       | `Pose3d`     | The mount pose, turned by the angle about the axis normal to the movement plane.                                     |
| `getTranslatedPose(Distance distance, Angle angle)` | `Pose3d`     | The mount pose, moved by the distance along the angle in the movement plane, and not turned.                         |
| `rotationInPlane(Angle angle)`                      | `Rotation3d` | The rotation of the angle about the axis normal to the movement plane.                                               |

***

## Getters

| Method                  | Returns                   | Description                                          |
| ----------------------- | ------------------------- | ---------------------------------------------------- |
| `getRelativePosition()` | `Optional<Translation3d>` | Where the mechanism is mounted, or empty if not set. |
| `getMovementPlane()`    | `Plane`                   | The plane the mechanism moves in.                    |

***

## Example

```java
// An elevator 0.1 m behind the robot's center, its carriage 0.15 m off the floor at zero height.
Elevator elevator = new Elevator(new ElevatorConfig()
    // ...
    .withMechanismPositionConfig(new MechanismPositionConfig()
        .withRelativePosition(new Translation3d(-0.1, 0, 0.15))), elevatorMotor);

// An arm on the carriage, its axis 0.2 m above it. It moves with the carriage.
Arm arm = new Arm(new ArmConfig()
    // ...
    .withMechanismPositionConfig(new MechanismPositionConfig()
        .withParent(elevator::getPose3d)
        .withRelativePosition(new Translation3d(0, 0, 0.2))), armMotor);

Telemetry.log("Robot/Components", new Pose3d[] {elevator.getPose3d(), arm.getPose3d()}, Pose3d.struct);
```


---

# 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://yams.yassrobotics.com/api-reference/java-reference/config/mechanism-position-config.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.
