Skip to content
CrocoDocs
Starter GuideProgrammingEngineeringDesignPortfolio
Documentation

Introduction

IntroductionBIOBUZZ game overview

Getting started

Getting startedBlocksOnBot JavaAndroid StudioYour first OpModeJava basicsMotors and servosNonblocking codeDebugging robot code

Control systems

Control systemsJoystick mappingField-centric mecanum drivePID controlFeedforwardFlywheel velocity controlSystem identificationMotion profilingKalman filterLow-pass filter

Autonomous

AutonomousTimed and encoder movementOdometryLocalization troubleshootingMotion planningReliable autonomous sequencesPure PursuitSensor fusionAuto to TeleOp handoff

Season topics

Season topicsProjectile mathematicsTurret aimingShooting on the move

Code practices

Code practicesNaming conventionsCode organizationLoop timing and bulk readsFormattingComments and documentationTeam collaboration

Libraries

LibrariesNextFTCFTCLibSolversLibPedro PathingRoad RunnerFTC DashboardMercurial v2Mercurial v1PanelsSloth

Community software

Community softwareBlaze FTCOpenLoopHive Vision

Sensors and vision

Vision overviewVision basicsLimelight 3A
Starter Guide
Engineering
Design
Portfolio
Appearance

Your first OpMode

Read the FTC lifecycle and run a complete telemetry-only Java program

An is a program selected on the . It runs on the , which talks to the , , and gamepads. The Driver Station selects, , starts, and stops that program.

Begin with telemetry rather than a moving . Telemetry is information your program sends to the Driver Station. It lets you check that the right program is installed and see what an input is doing.

File structure

In Android Studio, create HelloRobot.java inside TeamCode/src/main/java/org/firstinspires/ftc/teamcode/. For OnBot , create the corresponding Java OpMode using its editor. The public class and file names must match.

package org.firstinspires.ftc.teamcode;

import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;

@TeleOp(name = "Hello Robot", group = "Practice")
public class HelloRobot extends LinearOpMode {
    @Override
    public void runOpMode() {
        telemetry.addLine("Initialized. Press START to read the stick.");
        telemetry.update();

        waitForStart();
        if (!opModeIsActive()) return;

        while (opModeIsActive()) {
            double forward = -gamepad1.left_stick_y;
            telemetry.addData("Forward request", "%.2f", forward);
            telemetry.addData("A pressed", gamepad1.a);
            telemetry.update();
            idle();
        }
    }
}

The package identifies where the class belongs. Imports bring SDK types into scope. @TeleOp registers a driver-controlled program and gives it a Driver Station name. extends LinearOpMode selects the lifecycle used by this example. The SDK calls runOpMode(); you do not call it yourself.

Gamepad playground

This example uses the same active loop to drive a simulated robot. Play compiles, initializes, and starts the OpMode; the real Driver Station has separate INIT and START steps.

Press Play, click the , then hold W to drive forward or S to reverse. Release the key to remove power. Press Stop, change speed from 0.25 to 0.5 near the top of the code, and run it again. The same stick input now requests more power.

Drive with a gamepad
Open example in a new tab

Edit the example, then press Play. Reloading this page or changing theme restores the example.

On a narrow screen, Code and Simulator switch between the panes. On a touchscreen, use the left on-screen stick. This version adds motors so you can see the input take effect; the Hello Robot program above only sends telemetry to the Driver Station.

INIT, START, and STOP

Code before waitForStart() runs during INIT. Use it to map hardware, configure directions, and report readiness. A motor command here can run before START; initialization is not an automatic motion barrier.

waitForStart() waits for START or a stop request. The following active check handles STOP during that wait. while (opModeIsActive()) repeats the robot's work while it is allowed to run. idle() gives other work a chance to run; it is not a fixed timestep. Every inner movement loop also needs a stop check and a measured deadline.

For output devices, put shutdown in finally around the active work so an exception also removes motor power. See the motor example. Do not put a long calculation or an unguarded while (true) between stop checks.

Iterative OpModes

An iterative OpMode exposes init(), optional init_loop(), start(), repeated loop(), and stop(). Each loop() call should finish promptly so the SDK can call it again. A LinearOpMode gives you one method and lets you write your own active loop. Both can run responsive code; neither makes a blocking mechanism routine concurrent by itself.

First test

Build and deploy the TeamCode application in Android Studio, or build in OnBot Java. Select Hello Robot on the Driver Station. INIT should display the readiness message; START should display changing stick and button values. Move the left stick forward: the negated Y value should become positive. Press STOP and confirm the program ends.

Change the telemetry label, redeploy, and verify that the new label appears. This checks the edit–build–install loop before hardware adds another possible failure.

Sources

  • FTC SDK 12 samples — BasicOpMode_Linear.java and BasicOpMode_Iterative.java.
  • FTC programming documentation
  • Learn Java for FTC — a longer beginner course.
  • Crimson Crocs FTC Simulator playground — keyboard controls and the embedded execution environment.

Android Studio

Set up the FTC project and run one small Java OpMode

Java basics

Values, scope, conditions, loops, methods, and classes in robot code

On this page

File structureGamepad playgroundINIT, START, and STOPIterative OpModesFirst testSources