> For the complete documentation index, see [llms.txt](https://docs.raidrobotics.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.raidrobotics.org/programming/learning/control-theory.md).

# Control Theory

Control theory is how code makes a mechanism reach and hold a target, like an arm angle or an elevator height, even when the load changes. In FRC that mostly means two tools working together:

| Idea             | What it does                                                                                                                                 |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| Feedforward      | Predicts the output a mechanism needs, from what you know about it (gravity, friction, how fast you want it to move). Does most of the work. |
| PID feedback     | Measures the error between where the mechanism is and where it should be, and corrects it. Cleans up what feedforward misses.                |
| Motion profiling | Plans a smooth path to the target so the mechanism doesn't jerk.                                                                             |

## How to learn it

1. Read the controls section of the [WPILib docs](https://docs.wpilib.org): it covers PID, feedforward and profiles with interactive examples.
2. See how our code does it: the [Mechanisms guide](https://docs.raidrobotics.org/robot-template/guide/mechanisms.md) in the Robot Template shows the gains and profiles for each mechanism type.
3. Tune a mechanism in the [simulator](https://docs.raidrobotics.org/robot-template/getting-started/simulator.md) before the real robot.
4. Go deeper with the book below when you want the math behind it.

## Controls Engineering in FRC

A free book by Tyler Veness on the theory behind FRC control, from PID through state-space control. It's math-heavy; read it alongside the WPILib docs, not before them.

{% embed url="<https://file.tavsys.net/control/controls-engineering-in-frc.pdf>" %}


---

# 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://docs.raidrobotics.org/programming/learning/control-theory.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.
