WestlakeLEARN
FTC · Java

FIRST Tech Challenge

FTC · Java

  • Simple Autonomous
  • Encoder Autonomous
  • Autonomous State Machines
  • Actions and Sequencing
  • Build a Vision-Selected Autonomous

Actions and Sequencing

Prepare autonomous code for Road Runner action composition.

Module 8: Autonomous FoundationsAdvanced

In this lesson, you will:

  1. 01Write instant and running actions.
  2. 02Return completion correctly.
  3. 03Compose actions safely.

Concept narrative

Actions are reusable autonomous behaviors that continue until they report completion. This model aligns with Road Runner 1.0 and command-based robot thinking.

This lesson should be read as a robotics lesson first and a programming lesson second. The code matters because it lets the team create repeatable behavior under match pressure. Students should slow down long enough to name the inputs, outputs, assumptions, and safety limits before they touch the robot.

Robot mental model

An action is a cooperative task. It must do a small amount of work each time run is called, report telemetry, and finish when its condition is satisfied.

A good mental model gives the team a shared language. When a driver, builder, and programmer can point to the same behavior and use the same words, debugging gets calmer and code review becomes useful instead of personal.

Implementation walkthrough

Create one instant servo action and one encoder-wait action. Then compose them sequentially. Keep run calls short; do not hide sleeps inside custom actions.

Keep the implementation staged. First create the smallest version that compiles. Then add telemetry that proves it is running. Then connect one hardware device or one decision. Finally, repeat the test from a cold init so the team knows it was not a lucky hot reload.

MechanismAction.javaJava

public Action liftTo(int target) {
    return packet -> {
        lift.setTargetPosition(target);
        int error = target - lift.getCurrentPosition();
        packet.put("lift error", error);
        return Math.abs(error) > 25;
    };
}

Common mistakes and debugging

Returning false too soon starts the next action early; returning true forever stalls auto. Long blocking calls starve parallel actions.

Use the five-value debugging habit: input, state, target, measurement, output. If one of those values is missing, add it before rewriting logic. The goal is to make the robot tell the truth about what it thinks is happening.

Practice

Write an action that moves a lift until error is small, then use it in a sequence with a claw action.

Checkpoint

  • Action telemetry is useful.
  • Finish condition is tested.
  • No blocking sleeps in run.

Reflection check

Check your understanding before moving on.

What is the most important habit in Actions and Sequencing?

0 of 1 answered

References

Road Runner 1.0 ActionsAction composition, custom actions, and autonomous structure.FIRST FTC DocsOfficial SDK, Robot Controller, and programming reference.

Finished reading?

Mark this lesson complete — “Build a Vision-Selected Autonomous” is up next.

Autonomous State MachinesBuild a Vision-Selected Autonomous