FTC SDK Basics

beginner70 min

What is the FTC SDK?

The FTC Software Development Kit (SDK) is the Java library stack for FTC robots. It handles hardware access, OpModes, gamepads, and telemetry.

The SDK hides low-level hub details so you can focus on robot logic.

Learn more: FTC Docs: SDK Overview • FTC SDK GitHub

SDK Key Features

The SDK includes

  • Robot hardware control (motors, servos, sensors)
  • OpMode framework for autonomous and teleop code
  • Gamepad input handling
  • Telemetry for debugging and monitoring
  • Support for Control Hub and Expansion Hub

SDK structure

Layers separate hardware from your logic:

Hardware Layer: Direct communication with motors, servos, and sensors

Device Layer: Abstraction for consistent hardware access

OpMode Layer: Programming framework for robot modes

Application Layer: Your custom code

Key SDK classes

  • OpMode: Base class for robot programs. Extend it for autonomous or teleop. (OpMode API)

  • HardwareMap: Access configured devices by name. (HardwareMap API)

  • DcMotor, Servo, Sensor classes: Control actuators and read sensors. (DcMotor API, Servo API)

You use these classes in nearly every FTC program.

How an OpMode works

An OpMode is the class that runs during a match. The Driver Station lists OpModes annotated with @TeleOp or @Autonomous.

Two common bases: LinearOpMode (sequential code) and OpMode (repeated loop()). Most beginners start with LinearOpMode.

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

Basic TeleOp OpMode

import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
import com.qualcomm.robotcore.hardware.DcMotor;
import com.qualcomm.robotcore.hardware.Servo;

@TeleOp(name = "BasicTeleOp")
public class BasicTeleOp extends LinearOpMode {
    private DcMotor leftDrive, rightDrive;
    private Servo clawServo;

    @Override
    public void runOpMode() {
        // Map hardware
        leftDrive = hardwareMap.get(DcMotor.class, "left_drive");
        rightDrive = hardwareMap.get(DcMotor.class, "right_drive");
        clawServo = hardwareMap.get(Servo.class, "claw_servo");

        // Wait for the game to start
        waitForStart();

        // Run until the end of the match
        while (opModeIsActive()) {
            // Drive robot using joysticks
            double leftPower = -gamepad1.left_stick_y;
            double rightPower = -gamepad1.right_stick_y;
            leftDrive.setPower(leftPower);
            rightDrive.setPower(rightPower);

            // Open/close claw with buttons
            if (gamepad1.a) {
                clawServo.setPosition(1.0); // Open
            } else if (gamepad1.b) {
                clawServo.setPosition(0.0); // Close
            }

            // Show telemetry
            telemetry.addData("Left Power", leftPower);
            telemetry.addData("Right Power", rightPower);
            telemetry.addData("Claw Position", clawServo.getPosition());
            telemetry.update();
        }
    }
}

Hardware mapping

hardwareMap returns devices by the names you set in the Robot Controller configuration.

If a motor is named left_drive in configuration, use that exact string in code.

See FTC Docs: Configuring Your Hardware.

Hardware mapping example

DcMotor left = hardwareMap.get(DcMotor.class, "left_drive");
Servo claw = hardwareMap.get(Servo.class, "claw_servo");

Using telemetry

Telemetry sends values to the Driver Station during a match.

See gm0: Telemetry.

Telemetry example

telemetry.addData("Motor Power", left.getPower());
telemetry.addData("Servo Position", claw.getPosition());
telemetry.update();

Gamepad input

gamepad1 and gamepad2 expose sticks, buttons, and triggers.

See FTC Docs: Gamepad.

Gamepad input example

double drive = gamepad1.left_stick_y;
boolean openClaw = gamepad1.a;
boolean closeClaw = gamepad1.b;

Best Practices

Habits that reduce bugs

  • Initialize hardware in runOpMode() or init()
  • Use clear, descriptive names for hardware
  • Add telemetry for debugging
  • Handle exceptions gracefully
  • Comment your code
  • Test code on the robot frequently

Further reading

Next Steps

Practice: SDK Basics

Try these to reinforce your understanding:

  • Write an OpMode that initializes and drives one motor
  • Add telemetry to show motor power
  • Read gamepad input to control a servo
  • Practice using hardwareMap for different components