Lesson 2.1: Getting Your OpModes to Show Up with @TeleOp and @Autonomous
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.
Using parameters like name and group within the annotation provides human-readable labels and organized folders for the drivers. Alternatively, you can use @Disabled to hide the program from the compiler.
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)
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", group="Diagnostics")
public class IntakeDiagnostic extends OpMode {
...
}
Ready to move on?
Sign in with Google to save your progress with Telemark, or continue without saving.