Skip to lesson
Westlake RoboticsLearn
Vault

FIRST Tech Challenge

Loading progress…

  • LinearOpMode Lifecycle
  • Telemetry as Instrumentation
  • Hardware Map and Motors
  • Gamepad Input and Edge Detection

LinearOpMode Lifecycle

Understand init, start, active loop, and stop behavior.

FTC SDK FoundationsCore

In this lesson, you will:

  • Trace a LinearOpMode from init to stop.
  • Avoid blocking code that ignores stop.
  • Use lifecycle telemetry intentionally.

Concept narrative

LinearOpMode lets students write robot code as a readable sequence, but the SDK still controls the lifecycle. Code before waitForStart runs during init, code after waitForStart runs only after start, and every repeated behavior must respect opModeIsActive so the Stop button remains reliable.

Robot mental model

Imagine the robot waiting at the field wall. During init, it should map hardware, set safe positions, and report readiness. During active control, it should loop quickly. During stop, it should stop commanding motion. A match robot that ignores lifecycle boundaries is stressful and unsafe.

Implementation walkthrough

Write an OpMode with explicit init telemetry, a while loop for opModeInInit if needed, waitForStart, then the active loop. Put hardware setup before start and repeated gamepad/sensor decisions inside the active loop.

LifecycleDemo.javaJava

telemetry.addLine("Init complete");
telemetry.update();

waitForStart();
int loops = 0;

while (opModeIsActive()) {
    loops++;
    telemetry.addData("loops", loops);
    telemetry.addData("runtime", getRuntime());
    telemetry.update();
}

Common mistakes and debugging

If the robot moves during init, hardware writes are in the wrong place. If Stop is delayed, look for sleep calls or while loops that do not check opModeIsActive. If telemetry appears only once, telemetry.update is probably outside the loop.

Practice

Create a lifecycle demo that reports init time, start time, active loop count, and stop behavior. Explain which lines run before Start and which lines repeat during the match.

Checkpoint

  • Init telemetry appears before Start.
  • Loop count increases only after Start.
  • Stop exits promptly.
  • The test record includes the setup, prediction, and observed result.
  • A teammate can repeat the check from the saved evidence without guessing.

Reflection check

Check your understanding before moving on.

Where should a LinearOpMode map hardware and report readiness?
What protects the FTC Stop button when writing a repeated loop?

0 of 2 answered

References

FIRST FTC DocsOfficial SDK, Robot Controller, and programming reference.Learn Java for FTCFTC-focused Java book and exercises by Alan G. Smith.Game Manual 0FTC community reference for programming, controls, and robot design.
Loading lesson progress
Previous lessonEnums, Lists, and Team VocabularyNext lessonTelemetry as Instrumentation