> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nullftc.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Subsystems and Commands

> CommandKit, a powerful toolkit for building FTC command-based robots.

The command-based pattern is built around two core ideas: **commands** and **subsystems**.

***

## Commands

**Commands** represent actions the robot can take.
They are scheduled by the command scheduler and run until either:

* They finish naturally (their end condition is met), or
* They are interrupted by another command.

Commands can also be **composed** to build more complex robot behaviors from smaller, reusable pieces. For example, you might chain together a “drive forward” command, then a “turn,” then an “intake” command.

***

## Subsystems

**Subsystems** represent independent collections of hardware that work together — for example, a drivetrain, an arm, or an intake mechanism.

Subsystems serve two main purposes:

1. **Resource management**
   Only one command can control a subsystem at a time, which prevents conflicting hardware instructions.

2. **Abstraction**
   Subsystems hide hardware details behind a clean interface. This keeps your robot code simple and lets you change the internal hardware implementation without touching the rest of your code.

***

## How Commands Are Run

Commands and subsystems are tied together by the **scheduler**.

* The scheduler keeps track of which commands are running.
* It ensures that only one command at a time can use a given subsystem.
* Each iteration of the robot loop, the scheduler calls the appropriate methods on commands and subsystems to update behavior.

This structure makes robot code **modular, reusable, and easy to extend** — perfect for building complex autonomous routines or cleanly organizing teleop controls.
