Skip to main content

Lesson 2.5: Challenge — Build a Robot Health-Check OpMode with Telemetry


Context

A "Health-Check" routine prevents match-start failures by providing the drive team with real-time feedback on sensor readiness. By utilizing the full OpMode lifecycle, you can verify that the IMU is calibrated and the Control Hub is communicating before the match begins, reducing the likelihood of a dead robot on the field.


Robot Checks

This challenge requires integrating init(), init_loop(), and loop(). The init_loop() method is particularly powerful for professional teams — it runs repeatedly after "Init" but before "Play". This is where hardware-heavy tasks like IMU calibration or computer vision stream processing should occur. By using telemetry in init_loop(), the driver can wait for a "System Ready" message before starting the match.


Annotated Code

@TeleOp(name="Health_Check", group="Challenge")
public class HealthCheck extends OpMode {

@Override
public void init() {
// Setup initial software flags
telemetry.addData("Hub", "Initializing Sensors...");
}

@Override
public void init_loop() {
// This logic runs repeatedly while waiting for the match to start
// Ideal for checking if an IMU is finished calibrating
telemetry.addData("Pre-Match", "Check Battery and Gyro");
}

@Override
public void start() {
telemetry.addData("Match", "Running");
}

@Override
public void loop() {
// Standard match execution
}
}

Fill-in-the-Blank Practice

  1. The method __________ is useful for checking sensor values while the robot is stationary before the match starts.
  2. Providing data to the Driver Station screen is called __________.
  3. All methods in this unit come from the __________ parent class in the SDK.
Show answers
  1. init_loop()
  2. telemetry
  3. OpMode

Challenge

Create a master health-check program. Use init_loop() to show the driver the current runtime while they are waiting to press start, and use stop() to print "Robot Powering Down".

Unit 2 simulator
Supports `init()`, `init_loop()`, `start()`, `loop()`, and `stop()`.
Reads `@TeleOp`, `@Autonomous`, `@Disabled`, telemetry, and `gamepad1`.
Handles local variables, simple math, `resetRuntime()`, and `getRuntime()`.
Does not execute hardware, `gamepad2`, `else` blocks, or loop structures.
Show answer
@Override
public void init_loop() {
telemetry.addData("Waiting... Runtime", getRuntime());
}

@Override
public void stop() {
telemetry.addData("System", "Robot Powering Down");
}

Ready to move on?

Sign in with Google to save your progress with Telemark, or continue without saving.