> 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/c++-reference/gearing/mechanism-gearing.md).

# MechanismGearing

**Namespace:** `yams::gearing`\
**Header:** `#include <yams/gearing/MechanismGearing.hpp>`\
**Java equivalent:** [Java MechanismGearing](https://yams.yassrobotics.com/api-reference/java-reference/gearing/mechanism-gearing.md)\
**Doxygen:** [`MechanismGearing`](https://doxygen.yassrobotics.com/yams/classyams_1_1gearing_1_1MechanismGearing.html)

`MechanismGearing` is the composite gearing type accepted by `SmartMotorControllerConfig::WithMotorGearing()`. It may combine a `GearBox` with an optional `Sprocket`.

***

## Constants

```cpp
static const MechanismGearing kOne;  // 1:1 direct drive
```

***

## Constructors

```cpp
explicit MechanismGearing(double reductionRatio)  // same as GearBox::FromReductionStages({reductionRatio})
explicit MechanismGearing(const GearBox& gearBox)
MechanismGearing(const GearBox& gearBox, const Sprocket& sprockets)
```

***

## Methods

| Method                             | Returns             | Description                                                                                                   |
| ---------------------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------- |
| `GetRotorToMechanismRatio() const` | `double`            | Mechanism rotations per motor rotation (less than 1 for a reduction)                                          |
| `GetMechanismToRotorRatio() const` | `double`            | Motor rotations per mechanism rotation (the overall reduction, greater than 1 for a reduction)                |
| `Div(double i)`                    | `MechanismGearing&` | Calls `GearBox::Div(i)` on the gearbox stage (multiplies the reduction by `i`). Returns `*this` for chaining. |

***

## Example

```cpp
using namespace yams::gearing;

auto gearing = MechanismGearing{
    GearBox::FromTeeth({14, 72}),    // 5.14:1
    Sprocket::FromStages({"24:18"})  // 1.33:1
};
// Total: ~6.85:1

config.WithMotorGearing(gearing);
```

{% hint style="info" %}
`GetMechanismToRotorRatio()` is the overall reduction (motor rotations per mechanism rotation, greater than 1 for reductions). YAMS passes it as the gearing to the WPILib physics simulations. `GetRotorToMechanismRatio()` is its reciprocal.
{% endhint %}


---

# 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/c++-reference/gearing/mechanism-gearing.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.
