Lesson 2.1: Getting Your OpModes to Show Up with @TeleOp and @Autonomous
Technical Context
Sometimes valid Java classes fail to appear on the Driver Station menu. This is often due to incorrect annotation. In a competition environment, precise registration ensures the drive team can distinguish between driver-controlled programs and sensor-dependent autonomous routines, preventing the accidental execution of the wrong logic.
What Are Annotations?
Annotations in the FTC SDK are metadata tags that start with the @ symbol. When the Robot Controller app starts, it scans the TeamCode package for classes that extend OpMode and possess the @TeleOp or @Autonomous annotation. This process registers the class into the SDK's internal registry, allowing the Driver Station to build its user interface menu.
Because LinearOpMode extends OpMode, both TeleOp and Autonomous classes are still discovered through this same registration system.
Using parameters like name and group within the annotation provides human-readable labels and organized folders for the drivers. Adding @Disabled does not hide the class from the Java compiler; the code is still compiled. It tells the FTC SDK not to make that OpMode available in the Driver Station's selectable list. Remove or comment out @Disabled when the OpMode is ready to run, as shown in the official FTC sample.
Annotated Code
package org.firstinspires.ftc.teamcode;
// Importing the SDK classes required for OpMode registration
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
// REGISTER: This class appears as "DriveMain" in the TeleOp menu
@TeleOp(name="DriveMain", group="Competition")
public class ManualControl extends OpMode {
@Override
public void init() {
// Initialization logic for the Control Hub
telemetry.addData("Status", "Registered and Initialized");
}
@Override
public void loop() {
// Continuous hardware updates
}
}
Practice
- To register a program for the 30-second pre-programmed phase, the class must use the
__________annotation. - If you want to keep code in your project but hide it from the Driver Station menu, you must add the
__________annotation. - The
nameparameter inside the annotation defines the__________that will be visible to the drivers.
Show answers
@Autonomous@Disabled- The label (the text that appears in the Driver Station menu)
Simulator Challenge
Your team has a dedicated program for testing a new intake mechanism. Register this class as an Autonomous program named "Intake_Test" so it appears in the correct folder on the Driver Station.
Show answer
@Autonomous(name="Intake_Test")
public class IntakeDiagnostic extends OpMode {
@Override
public void init() {
telemetry.addData("System", "Intake Logic Loaded");
}
@Override
public void loop() {
// Logic for motor testing
}
}
Ready to move on?
Only mark complete if you genuinely understand the material. Your progress will be saved in this browser.
Stuck on this lesson?
Ask about anything on this page. It can see which lesson you have open and which part you are reading.