> 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/tutorials/advantagekit-integration/io-interface.md).

# Step 1: Define the IO interface

The IO interface lists what the arm reads (its inputs) and what it can be told to do. Following AdvantageKit conventions, the inputs are grouped in an `Inputs` class. This needs AdvantageKit installed, from [Step 0: Install AdvantageKit and set up Robot](https://yams.yassrobotics.com/documentation/tutorials/advantagekit-integration/setup.md).

The inputs are plain numbers with the unit in the name, as AdvantageKit's own examples do. The methods that command the mechanism take WPILib units (`Angle`), so a caller cannot mix up degrees and rotations.

The tutorial builds an arm. The [elevator and shooter](https://yams.yassrobotics.com/documentation/tutorials/advantagekit-integration/elevator-and-shooter.md) follow the same steps, and have their own page at the end.

## Arm IO interface

Create `ArmIO.java` in a new `akit` folder: `subsystems/akit` for Commands v2, or `mechanisms/akit` for Commands v3. The two tabs differ only in the `package` line.

{% tabs %}
{% tab title="Java, Commands v2" %}

```java
package first.robot.subsystems.akit;

import org.littletonrobotics.junction.AutoLog;
import org.wpilib.units.measure.Angle;

public interface ArmIO {

  /**
   * Inputs that will be logged and replayed.
   * The @AutoLog annotation generates the ArmIOInputsAutoLogged class.
   */
  @AutoLog
  public static class ArmIOInputs {
    public double positionRotations = 0.0;
    public double velocityRotationsPerSec = 0.0;
    public double appliedVolts = 0.0;
    public double supplyCurrentAmps = 0.0;
    public double statorCurrentAmps = 0.0;
    public double temperatureCelsius = 0.0;
    public double targetPositionRotations = 0.0;
  }

  /** Update the inputs from hardware. Called every loop cycle. */
  default void updateInputs(ArmIOInputs inputs) {}

  /** Set the target angle for the arm. */
  default void setTargetAngle(Angle angle) {}

  /** Stop the arm motor. */
  default void stop() {}

  /** Run the arm's simulation for one loop. */
  default void simIterate() {}

  /** Publish the arm's YAMS telemetry. */
  default void updateTelemetry() {}
}
```

{% endtab %}

{% tab title="Java, Commands v3" %}

```java
package first.robot.mechanisms.akit;

import org.littletonrobotics.junction.AutoLog;
import org.wpilib.units.measure.Angle;

public interface ArmIO {

  /**
   * Inputs that will be logged and replayed.
   * The @AutoLog annotation generates the ArmIOInputsAutoLogged class.
   */
  @AutoLog
  public static class ArmIOInputs {
    public double positionRotations = 0.0;
    public double velocityRotationsPerSec = 0.0;
    public double appliedVolts = 0.0;
    public double supplyCurrentAmps = 0.0;
    public double statorCurrentAmps = 0.0;
    public double temperatureCelsius = 0.0;
    public double targetPositionRotations = 0.0;
  }

  /** Update the inputs from hardware. Called every loop cycle. */
  default void updateInputs(ArmIOInputs inputs) {}

  /** Set the target angle for the arm. */
  default void setTargetAngle(Angle angle) {}

  /** Stop the arm motor. */
  default void stop() {}

  /** Run the arm's simulation for one loop. */
  default void simIterate() {}

  /** Publish the arm's YAMS telemetry. */
  default void updateTelemetry() {}
}
```

{% endtab %}
{% endtabs %}

Every method has an empty default, so the replay IO class in [Log replay](https://yams.yassrobotics.com/documentation/tutorials/advantagekit-integration/log-replay.md) can leave them all out.

{% hint style="info" %}
The `@AutoLog` annotation from AdvantageKit generates a class (`ArmIOInputsAutoLogged`) that writes the inputs to the log, and reads them back in replay. See the [AdvantageKit AutoLog documentation](https://docs.advantagekit.org/data-flow/recording-inputs/io-interfaces#autolog) for details.

AdvantageKit logs each field with its first letter capitalized, so `positionRotations` shows up as `Arm/PositionRotations`.
{% endhint %}

**Check:** build the project. It succeeds, and `ArmIOInputsAutoLogged` can be imported (it is generated under `build/generated`).

**If it did not work:** if `ArmIOInputsAutoLogged` is not generated, check the line from [Add the AutoLog code generator](https://yams.yassrobotics.com/documentation/tutorials/advantagekit-integration/setup.md#add-the-autolog-code-generator), then clean the project with `gradlew clean` (Windows) or `./gradlew clean` (Linux/macOS) and build again. If it still does not generate, try commenting out the `annotationProcessor wpi.java.deps.wpilibAnnotations()` line and clean again.


---

# 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/tutorials/advantagekit-integration/io-interface.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.
