> 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/understanding/simulation-only-pid-+-feedforward.md).

# Simulation-only PID + feedforward

A simulated mechanism is an ideal motor and load: no friction, no backlash, no cable drag, and exactly the mass you told YAMS. A real mechanism has all of those. So the gains that hold a real arm usually do something different in simulation, and the other way round. `withSimClosedLoopController` and `withSimFeedforward` let you keep one set of gains for each, so tuning one never breaks the other.

## An example

An arm tuned on the real robot needed `kS = 0.15 V` to get past friction and `kG = 0.35 V` to hold it level. In simulation there is no friction, and the simulated arm is a little lighter than the real one with its wiring and bolts:

```java
.withClosedLoopController(4, 0, 0.2)                 // real robot
.withFeedforward(new ArmFeedforward(0.15, 0.35, 1.2)) // real robot: kS, kG, kV
.withSimClosedLoopController(4, 0, 0.2)              // simulation: the same PID
.withSimFeedforward(new ArmFeedforward(0, 0.30, 1.2)) // simulation: no friction, a lighter arm
```

With the real `kS` in simulation, the arm would push 0.15 V harder than it needs to and overshoot every small move. With the real `kG`, it would creep upward when it should hold still. Each set is right for its own mechanism.

## When you need it

* **Leave them out at first.** Without them, simulation uses your real gains. That is fine while you are getting a mechanism moving.
* **Add them once the real robot is tuned**, if simulation then behaves worse than it did. Tune the simulation gains in simulation with [live tuning](https://yams.yassrobotics.com/documentation/how-to-tuning/live-tuning.md), the same way as the real ones.
* **Do not tune the real robot in simulation.** Gains found in simulation are a starting point at best: [Step 5 of the Arm tutorial](https://yams.yassrobotics.com/documentation/tutorials/arm/tune.md) tunes them on the robot.

[`withSimClosedLoopController` and `withSimFeedforward`](https://yams.yassrobotics.com/documentation/reference/editor/config/simulation.md#withsimclosedloopcontroller-and-withsimfeedforward) list the options, including slots.


---

# 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/understanding/simulation-only-pid-+-feedforward.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.
