> For the complete documentation index, see [llms.txt](https://yagsl.yassrobotics.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yagsl.yassrobotics.com/reference/json-schema/swervedrive-json.md).

# swervedrive.json

Top-level drive configuration. Parsed into `swervelib.core.parser.json.SwerveDriveJson`.

```json
{
  "gyro": {
    "type": "pigeon2_can",
    "id": 0,
    "canbus": ""
  },
  "gyroAxis": "yaw",
  "gyroInvert": false,
  "modules": ["frontleft.json", "frontright.json", "backleft.json", "backright.json"]
}
```

| Field        | Type                                                  | Required             | Description                                                                                                                                                                    |
| ------------ | ----------------------------------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `gyro`       | [Device](/reference/json-schema/device-types.md#gyro) | yes                  | The robot's gyroscope. See [Device type strings](/reference/json-schema/device-types.md#gyro) for valid `type` values.                                                         |
| `gyroAxis`   | string enum                                           | no (default `"yaw"`) | Which axis of the gyro points up through the robot and is read as the heading: `yaw`, `pitch`, or `roll`. Passed to YAMS as `SwerveDriveConfig.withGyroHeadingAxis(GyroAxis)`. |
| `gyroInvert` | boolean                                               | yes                  | Invert the gyroscope's heading reading. Passed to YAMS as `SwerveDriveConfig.withGyroInverted(boolean)`; the parser does not invert the gyro itself.                           |
| `modules`    | string\[]                                             | yes                  | Filenames (relative to the `modules/` directory) of each module's JSON file, minimum 3, listed clockwise from front-left by convention.                                        |

## `gyro` object

| Field    | Type   | Description                                                                                                                                                                                                                                                                   |
| -------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `type`   | string | Gyro type string, see [Device type strings](/reference/json-schema/device-types.md#gyro). Set to `custom` to skip YAGSL's gyro setup and configure the gyro yourself; see [Custom Gyro](/reference/hardware/gyroscopes.md#custom-gyro).                                       |
| `id`     | number | CAN ID. Set to `0` if the gyro doesn't need one (`systemcore_internal`, `custom`).                                                                                                                                                                                            |
| `canbus` | string | CAN bus the gyro is on: `""` for the SystemCore bus `can_s0`, or the bus number, such as `"1"` for `can_s1`. A Pigeon 2 also takes a CANivore's name. See [CAN buses](/reference/json-schema.md#control-system-and-can-buses). Ignored by `systemcore_internal` and `custom`. |

{% hint style="info" %}
When `gyro.type` is `custom`, `gyroAxis` and `gyroInvert` above are also ignored. The parser never calls `SwerveDriveConfig.withGyro()`/`withGyroHeadingAxis()`/`withGyroInverted()`, so you must call them yourself.
{% 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://yagsl.yassrobotics.com/reference/json-schema/swervedrive-json.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.
