> 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/sprocket.md). Agents can also search and read this documentation through its [MCP server](https://yams.yassrobotics.com/~gitbook/mcp).

# Sprocket

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

`Sprocket` models a chain or belt drive stage. The API is identical to `GearBox`; the distinction is semantic. Use `GearBox` for meshed gears.

***

## Constructors

```cpp
explicit Sprocket(double reductionStage)
explicit Sprocket(std::initializer_list<double> reductionStages)
explicit Sprocket(const std::vector<double>& reductionStages)
explicit Sprocket(const std::vector<std::string>& stages)  // "IN:OUT" format
```

***

## Factory methods

```cpp
static Sprocket FromStages(std::initializer_list<std::string_view> stages)  // "IN:OUT"
```

{% hint style="info" %}
`Sprocket` does not provide `FromTeeth`. Use `FromStages` with `"IN:OUT"` strings, parsed as `IN / OUT` reductions (e.g., `"36:18"` for an 18T driving sprocket and a 36T driven sprocket, a 2:1 reduction).
{% endhint %}

***

## Methods

| Method                                     | Returns     | Description                                                                                                           |
| ------------------------------------------ | ----------- | --------------------------------------------------------------------------------------------------------------------- |
| `GetInputToOutputConversionFactor() const` | `double`    | Mechanism rotations per motor rotation (less than 1 for a reduction)                                                  |
| `GetOutputToInputConversionFactor() const` | `double`    | Motor rotations per mechanism rotation (the reduction ratio itself)                                                   |
| `Times(double x)`                          | `Sprocket&` | Multiplies the input-to-output conversion factor by `x` (divides the reduction by `x`). Returns `*this` for chaining. |
| `Div(double x)`                            | `Sprocket&` | Divides the input-to-output conversion factor by `x` (multiplies the reduction by `x`). Returns `*this` for chaining. |

***

## Exceptions

| Exception                                | Thrown When                                |
| ---------------------------------------- | ------------------------------------------ |
| `exceptions::NoStagesGivenException`     | Stage list is empty                        |
| `exceptions::InvalidStageGivenException` | A string stage is not in `"IN:OUT"` format |

***

## Example

```cpp
// 18T driving sprocket, 36T driven sprocket = 2:1
auto s = yams::gearing::Sprocket::FromStages({"36:18"});

// Multi-stage belt drive: 2:1 then 2:1 = 4:1
auto s2 = yams::gearing::Sprocket::FromStages({"36:18", "24:12"});
```


---

# 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/sprocket.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.
