> 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/documentation/reference/editor/config.md).

# SmartMotorControllerConfig

A `SmartMotorControllerConfig` describes one motor: how it is geared, how it is controlled, what it must not do and what it reports. You write it once, in the same way for every vendor, and hand it to a wrapper such as `TalonFXWrapper`, `SparkWrapper`, `NovaWrapper` or `A301Wrapper`.

<figure><img src="https://1354553280-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZM0CFmYiQzcrY4zDcTtZ%2Fuploads%2Fgit-blob-d1ba4ddca3f93cf600dca36387e9fe00588c5e07%2Fsmc-config-map.png?alt=media" alt="A grid of nine groups of SmartMotorControllerConfig options: motor basics, gearing and units, closed loop control, feedforward, motion profiles, limits and protection, encoders, followers and simulation, each listing its main methods."><figcaption><p>The option groups. Each has its own page.</p></figcaption></figure>

## Where to find each option

| Page                                                                                                                  | What it covers                                                                                    |
| --------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| [Motor basics](https://yams.yassrobotics.com/documentation/reference/editor/config/motor-basics.md)                   | Control mode, inversion, brake or coast, starting from a clean config, vendor configs, telemetry. |
| [Gearing and units](https://yams.yassrobotics.com/documentation/reference/editor/config/gearing-and-units.md)         | Gear ratios, circumference, wheels and drums, cascading elevator stages.                          |
| [Closed loop control](https://yams.yassrobotics.com/documentation/reference/editor/config/closed-loop-control.md)     | PID gains, slots, tolerance, continuous wrapping, output limits, where the loop runs.             |
| [Feedforward](https://yams.yassrobotics.com/documentation/reference/editor/config/feedforward.md)                     | Simple, arm and elevator feedforwards and what each gain does.                                    |
| [Motion profiles](https://yams.yassrobotics.com/documentation/reference/editor/config/motion-profiles.md)             | Trapezoidal, velocity and exponential profiles.                                                   |
| [Limits and protection](https://yams.yassrobotics.com/documentation/reference/editor/config/limits-and-protection.md) | Soft limits, current limits, ramp rates, voltage compensation, temperature cutoff.                |
| [Encoders](https://yams.yassrobotics.com/documentation/reference/editor/config/encoders.md)                           | Starting position, encoder inversion, external encoders and their zero offset.                    |
| [Followers](https://yams.yassrobotics.com/documentation/reference/editor/config/followers.md)                         | Followers on one shaft, and loosely coupled followers.                                            |
| [Simulation](https://yams.yassrobotics.com/documentation/reference/editor/config/simulation.md)                       | Simulation-only gains, starting position, moment of inertia and step size.                        |

## How the config is used

<figure><img src="https://1354553280-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZM0CFmYiQzcrY4zDcTtZ%2Fuploads%2Fgit-blob-7cb7fb9be9c63e0d415bf43596902cf1545a256c%2Fsmc-config-flow.png?alt=media" alt="A flow diagram. Your SmartMotorControllerConfig goes to a wrapper such as TalonFXWrapper, SparkWrapper or NovaWrapper, which translates each option into the vendor&#x27;s own config, which is sent once at startup to the motor controller. An option the controller cannot do throws an exception at startup that names the method to change."><figcaption><p>The same config works for every supported motor controller.</p></figcaption></figure>

```java
SmartMotorControllerConfig config = new SmartMotorControllerConfig(this)
    .withControlMode(ControlMode.CLOSED_LOOP)
    .withGearing(new MechanismGearing(GearBox.fromReductionStages(3, 4)))
    .withClosedLoopController(4, 0, 0)
    .withFeedforward(new ArmFeedforward(0, 0.3, 1.2))
    .withTrapezoidalProfile(DegreesPerSecond.of(180), DegreesPerSecondPerSecond.of(360))
    .withSoftLimits(Degrees.of(-20), Degrees.of(100))
    .withStatorCurrentLimit(Amps.of(40))
    .withZeroPower(MotorMode.BRAKE)
    .withTelemetry("ArmMotor", TelemetryVerbosity.HIGH);

SparkMax spark = new SparkMax(CANPort.CAN_S0, 4, MotorType.kBrushless);
SmartMotorController motor = new SparkWrapper(spark, DCMotor.getNEO(1), config);
```

This is a fragment: it goes inside a subsystem, which is the `this` passed to the config. [Step 1 of the Arm tutorial](https://yams.yassrobotics.com/documentation/tutorials/arm/motor-controller.md) builds the same thing as a complete file.

Three things are worth knowing before reading the option pages:

* **Every `with...()` method returns the config**, so options chain. A few options depend on an earlier one and say so on their page, for example `withClosedLoopTolerance` needs a PID controller first.
* **Options are checked when the wrapper is created.** An option that motor controller cannot do throws an exception, so problems show up at startup and not mid-match. It is usually a `SmartMotorControllerConfigurationException` that names the method to change, and for a few options an `IllegalArgumentException`. Each option says which.
* **The motor's config holds the motor's limits.** Soft limits, starting position and gearing go on the `SmartMotorControllerConfig`, even when a mechanism uses the motor. The mechanism's own config (`ArmConfig`, `ElevatorConfig` and so on) describes the mechanism: its length, mass and hard stops.

## Not every option works on every motor controller

{% hint style="warning" %}
Motor controllers differ. Some options only exist on one of them, and some only work in certain situations, for example only when the closed loop runs on the SystemCore. An option a controller cannot do normally throws a `SmartMotorControllerConfigurationException` or an `IllegalArgumentException` at startup, but check the table for each option you rely on.
{% endhint %}

Every option on the following pages has a table showing where it works. The [motor controller feature matrix](https://yams.yassrobotics.com/documentation/reference/editor/feature-matrix.md#feature-support-matrix) has every option against every motor controller in one place. The ones that most often catch teams out:

* **TalonFX and TalonFXS:** no [`withClosedLoopTolerance`](https://yams.yassrobotics.com/documentation/reference/editor/config/closed-loop-control.md#withclosedlooptolerance), no [`withVoltageCompensation`](https://yams.yassrobotics.com/documentation/reference/editor/config/limits-and-protection.md#withvoltagecompensation), no `SLOT_3`, and [`withEncoderInverted`](https://yams.yassrobotics.com/documentation/reference/editor/config/encoders.md#withencoderinverted) only on a TalonFXS.
* **SPARK MAX and SPARK Flex:** no [supply current limit](https://yams.yassrobotics.com/documentation/reference/editor/config/limits-and-protection.md#withstatorcurrentlimit-and-withsupplycurrentlimit) and no [`withVendorControlRequest`](https://yams.yassrobotics.com/documentation/reference/editor/config/motor-basics.md#withvendorcontrolrequest). Several options only work when the loop runs on the SystemCore, with an exponential profile or an [LQR](https://yams.yassrobotics.com/documentation/understanding/lqr-controllers.md).
* **Thrifty Nova:** two closed loop slots, both soft limits or neither, and [one ramp rate](https://yams.yassrobotics.com/documentation/reference/editor/config/limits-and-protection.md#withopenloopramprate-and-withclosedloopramprate) for open and closed loop control. Like a SPARK, several options only work when the loop runs on the SystemCore. Wrapping the Nova can't do runs the loop on the SystemCore.
* **FIRST A301:** no current limits, ramp rates, voltage compensation, vendor config or [`withFollowers`](https://yams.yassrobotics.com/documentation/reference/editor/config/followers.md#withfollowers) (use loosely coupled followers), and its only external encoder is its own. Every closed loop runs on the SystemCore, and [soft limits](https://yams.yassrobotics.com/documentation/reference/editor/config/limits-and-protection.md#withsoftlimits) only move position setpoints.
* **Everywhere:** [soft limits](https://yams.yassrobotics.com/documentation/reference/editor/config/limits-and-protection.md#withsoftlimits) only work in closed loop mode, and [`withVendorConfig`](https://yams.yassrobotics.com/documentation/reference/editor/config/motor-basics.md#withvendorconfig), [`withExternalEncoder`](https://yams.yassrobotics.com/documentation/reference/editor/config/encoders.md#withexternalencoder) and [`withFollowers`](https://yams.yassrobotics.com/documentation/reference/editor/config/followers.md#withfollowers) only take that vendor's own parts.

Many of these depend on where the closed loop runs, which is explained in [where the loop runs](https://yams.yassrobotics.com/documentation/reference/editor/config/closed-loop-control.md#where-the-loop-runs).

## Changing a config later

Most options can be changed while the robot runs through [live tuning](https://yams.yassrobotics.com/documentation/how-to-tuning/live-tuning.md), which is the quickest way to find gains and limits. Once you have them, put the numbers back in the config so they survive a restart.

## Code reference

* [`SmartMotorControllerConfig`](https://javadocs.yassrobotics.com/yams/yams/core/motorcontrollers/SmartMotorControllerConfig.html)


---

# 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/documentation/reference/editor/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.
