Skip to content
Week 4 · Lesson 2 50 min

The FTC SDK, Programming Tools and Robot Configuration

Meet the FTC SDK and its three programming tools, then create a robot configuration on the Control Hub whose device names match your code exactly.

In this lesson you will

  • Describe what the FTC SDK, the Robot Controller app and the Driver Station app each do.
  • Compare Blocks, OnBot Java and Android Studio and choose a starting tool for your team.
  • Create, save and activate a robot configuration on the Control Hub.
  • Explain why every configuration name must exactly match the name used in hardwareMap.get.

Lesson

The FTC SDK (Software Development Kit) is the official software from FIRST that every team builds on. It contains the Robot Controller app that runs on the Control Hub, the libraries for motors, servos and sensors, and many sample OpModes. Your programs, called OpModes, become part of the Robot Controller app. The Driver Station app runs on the Driver Hub or phone: it lets drivers pick an OpMode, start and stop it, sends gamepad input to the robot and shows messages from the robot.

Driver HubGamepadsControl HubCPU · IMU · I/OBattery 12 VSwitchWi-FiMotorsServosSensors
The Driver Station sends gamepad data over Wi-Fi to the Control Hub, which runs your OpMode and powers the motors and servos.

Follow the path of one action. A driver pushes a joystick. The Driver Station reads the gamepad and sends the values over Wi-Fi. Your OpMode on the Control Hub reads gamepad1, calculates a power, and calls setPower. The Control Hub sends that power to a motor port, and the wheel turns. Messages you send with telemetry travel back the same way to the Driver Station screen. The 12 V battery powers everything on the robot through the main power switch.

Three ways to program

ToolWhere you write codeStrengthsTrade-offs
BlocksA web browser connected to the Control HubDrag-and-drop, no typing errors, quick to learnLarge programs become hard to read and organise
OnBot JavaA web browser; code is stored and compiled on the Control HubReal Java with nothing to installSimple editor and no built-in version control
Android StudioA full IDE on your computer, using the FtcRobotController project from GitHubAutocomplete, Git, libraries, best for big projectsNeeds installation and setup; you deploy code over USB or Wi-Fi

To open Blocks or OnBot Java, connect your laptop to the Control Hub's Wi-Fi network and open the Robot Controller Console in a browser at 192.168.43.1:8080. A good path for a new team is to start in OnBot Java, because the code is exactly the Java you will later use in Android Studio. Blocks is a fine choice if your programmers have never typed code before: the ideas (variables, loops, hardwareMap, gamepad) are identical. This module shows Java.

Robot configuration: telling the hub what is plugged in

The Control Hub cannot see what kind of device is on each port or what you want to call it. A robot configuration is a saved list that says: 'on motor port 0 there is this type of motor, and its name is left_front'. Your code then asks for devices by those names. You can store several configurations, but only the active one is used.

  1. 1
    Connect
    Power on the robot and make sure the Driver Station shows it is connected to the Control Hub.
  2. 2
    Open the menu
    On the Driver Station, open the menu (three dots) and choose Configure Robot, then New.
  3. 3
    Select the hub
    Choose the Control Hub Portal, then the Control Hub (and the Expansion Hub, if you have one).
  4. 4
    Add motors
    Open Motors, choose the matching motor type for each used port, and type a name for each one.
  5. 5
    Add servos and sensors
    Open Servos and set the type (Servo or Continuous Rotation Servo) and a name. Add sensors on the I2C or digital ports the same way.
  6. 6
    Save and activate
    Press Done until asked to save, give the configuration a clear name, and make sure it is shown as the active configuration.
HubPortDevice typeName in code
Control HubMotor 0Your motor model (for example a goBILDA or REV HD Hex motor)left_front
Control HubMotor 1Same modelleft_back
Control HubMotor 2Same modelright_front
Control HubMotor 3Same modelright_back
Control HubServo 0Servoclaw
Control HubI2C bus 0Built-in IMU (usually added automatically)imu

Hardware mapping: names must match exactly

In code, the hardwareMap object gives you devices from the active configuration. You tell it the device class and the configuration name. Java then gives you an object you can control. The name in quotes must match the configuration character for character, including capital letters, underscores and spaces.

JAVA
1// Inside runOpMode(), before waitForStart()
2DcMotor leftFront  = hardwareMap.get(DcMotor.class, "left_front");
3DcMotor rightFront = hardwareMap.get(DcMotor.class, "right_front");
4Servo claw         = hardwareMap.get(Servo.class, "claw");
5
6// Needed imports at the top of the file:
7// import com.qualcomm.robotcore.hardware.DcMotor;
8// import com.qualcomm.robotcore.hardware.Servo;
Getting devices from the active configuration by name
  • Use short, lowercase names with underscores, such as left_front or arm_motor.
  • Describe position or job, not the port number, so the name still makes sense if you move a cable.
  • Put a label on each cable and port so the wiring matches the configuration.
  • Write the full configuration table in your engineering portfolio and on the team whiteboard.

Key terms

FTC SDK
The official software kit from FIRST containing the Robot Controller app, hardware libraries and sample OpModes that teams build on.
OpMode
A program you write that the drivers can select and run from the Driver Station, either TeleOp or Autonomous.
Robot configuration
A saved list on the Control Hub that gives each port a device type and a name.
hardwareMap
The SDK object that returns devices from the active configuration when you ask for them by class and name.
Robot Controller Console
The web page served by the Control Hub where you write Blocks and OnBot Java programs and manage files.

Practical exercise

Configure your robot

  1. 1Update the Control Hub and Driver Station with the REV Hardware Client and confirm the app versions match.
  2. 2Draw a table of every motor and servo on your robot with its hub, port and a planned name.
  3. 3Create a new configuration on the Driver Station using exactly those names, then save and activate it.
  4. 4Open the Robot Controller Console at 192.168.43.1:8080 and create a new OnBot Java (or Blocks) OpMode file.
  5. 5Write the hardwareMap.get lines for every device and build the code with no errors.
Deliverable: A photo of your configuration table next to the robot, and a screenshot of the built code containing one hardwareMap.get line per device.

Knowledge check

Answer every question, then check your answers.

  1. Q1Which device runs your OpMode code during a match?
  2. Q2Your configuration names a motor arm_motor. Which line will find it?
  3. Q3What is a good reason for a new team to choose OnBot Java?
  4. Q4You made two configurations. Which one does hardwareMap use?

Further resources

Mark lesson complete