FTC SDK Basics

What is the FTC SDK?

The FTC (FIRST Tech Challenge) Software Development Kit (SDK) is the foundation for programming FTC robots in Java. It provides all the libraries, APIs, and tools needed to control robot hardware, manage OpModes, and interact with sensors and gamepads.

The SDK abstracts away low-level hardware details, letting you focus on robot logic.

Learn more: FTC Docs: SDK OverviewFTC SDK GitHub

SDK Key Features

The FTC SDK provides:

  • 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

The SDK is organized into layers that separate hardware access from your robot logic. This makes it easier to write, debug, and maintain your code.

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

The most important classes in the SDK are:

- OpMode: The base class for all robot programs. You extend this to create your own autonomous or teleop code. (OpMode API)
- HardwareMap: Lets you access configured hardware devices by name. (HardwareMap API)
- DcMotor, Servo, Sensor classes: Used to control motors, servos, and sensors. (DcMotor API, Servo API)

You will use these classes in almost every FTC program.

How an OpMode Works

An OpMode is a class that controls your robot during a match. You write your robot's logic inside an OpMode, and the Driver Station app lets you select and run it.

There are two main types: LinearOpMode (runs code sequentially) and OpMode (runs code in a 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 Explained

The hardwareMap object lets you access motors, servos, and sensors by the names you set in the Robot Controller app.

For example, if you named a motor 'left_drive' in your configuration, you can access it in code as shown below.

See FTC Docs: Configuring Your Hardware for more.

Hardware Mapping Example

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

Using Telemetry

Telemetry lets you send data to the Driver Station for debugging and monitoring. You can display motor power, sensor values, or any other information you want to see during a match.

See gm0: Telemetry for more.

Telemetry Example

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

Gamepad Input Explained

The SDK provides two gamepad objects, gamepad1 and gamepad2, for reading driver and operator controls. You can read joystick, button, and trigger values to control your robot.

See FTC Docs: Gamepad for a full list of controls.

Gamepad Input Example

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

Best Practices

For robust FTC code:

  • 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 & Resources

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

Open full interactive app