# Device Configuration

## Device Configuration

All devices in a swerve drive come down to a basic set of fields. The device configuration is used to store and create those devices during parsing with a 1:1 mapping to [`DeviceJson`](https://docs.yagsl.com/configuring-yagsl/configuration/device-configuration).

## Fields

<table data-full-width="true"><thead><tr><th>Name</th><th>Units</th><th>Required</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><a href="/pages/cvukjHkcjufr6BOm0AFh#possible-absolute-encoder-types">Encoder <code>type</code></a><br><a href="/pages/nEGjJWQbq59bdD018IBm#possible-gyroscope-types">IMU <code>type</code></a><br><a href="/pages/Uxpevbhfh3qJnv5KKSAx#possible-motor-controller-types">Motor <code>type</code></a></td><td>Y</td><td>The device type which is used for creation of the Swerve type.</td></tr><tr><td><code>id</code></td><td>Integer</td><td>Y</td><td>The ID of the device on the CANBus, or the pin ID on the roboRIO for certain devices.</td></tr><tr><td><code>canbus</code></td><td>String</td><td>N</td><td>The canbus to instantiate the device on. Only works on devices compatible with alternate CAN buses.<br><br>When the <code>type</code> is <code>sparkmax_brushed</code> this defines the encoder attached to the motor which is required for drive motors, angle motors should also use them if there is no attached absolute encoder. The valid values in this case are <code>greyhill_63r256</code>, <code>srx_mag_encoder</code>, <code>throughbore</code>, <code>throughbore_dataport</code>, <code>greyhill_63r256_dataport</code>, <code>srx_mag_encoder_dataport</code>.<br>DO NOT SET THIS IF THE ATTACHED ENCODER IS AN ABSOLUTE ENCODER</td></tr></tbody></table>

## Useful tips

1. Optimize your IMU if it isn't as accurate as you hope, NavX's have this nice guide [here](https://pdocs.kauailabs.com/navx-mxp/guidance/best-practices/)
2. Read the code! If you can't understand something all of the code is documented and easy to read.


---

# Agent Instructions: 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:

```
GET https://docs.yagsl.com/configuring-yagsl/configuration/device-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
