Basic Autonomous Programming (OnBot Java)

intermediate50 min

Autonomous period

For the first 30 seconds of each match (length may vary by season), the robot runs without gamepad input. Your @Autonomous OpMode runs during this time.

Autonomous OpMode structure

Extend LinearOpMode, annotate with @Autonomous, and put actions after waitForStart().

See FTC Docs: Creating and Running an Op Mode (OnBot Java).

Minimal autonomous example

@Autonomous(name="MyFirstAutonomous")
public class MyFirstAutonomous extends LinearOpMode {
    @Override
    public void runOpMode() {
        // Initialization code here
        telemetry.addData("Status", "Initialized");
        telemetry.update();

        // Wait for the game to start (driver presses PLAY)
        waitForStart();

        // Autonomous actions go here
        while (opModeIsActive()) {
            // Example: do nothing
            telemetry.addData("Status", "Running");
            telemetry.update();
        }
    }
}

Practice Exercise: Your First Autonomous OpMode

Write an autonomous OpMode that drives a motor for 2 seconds, then stops. Use telemetry to display status before, during, and after movement.

  • Map a DC motor using hardwareMap.
  • Use waitForStart() to wait for the match to begin.
  • Set the motor power to drive forward for 2 seconds.
  • Stop the motor and update telemetry.

Further Reading & Resources