WestlakeLEARN
FTC / Java

First Tech Challenge

FTC / Java

01 · Java for FTC
  • OpMode Anatomy and Hello Robot
  • Variables, Math, and Decisions
  • Methods, Classes, and Robot Helpers
02 · FTC Hardware Essentials1/3
  • Hardware Map and RobotHardware
  • Motors, Servos, and Sensors
  • IMU, Encoders, and Bulk Caching
03 · TeleOp and Mecanum
  • Robot-Centric Mecanum Drive
  • Field-Centric Driving
  • Driver Ergonomics and Safe TeleOp
04 · Subsystems and Commands
  • Subsystem Lifecycle
  • Enums and Finite State Machines
  • Command-Based OpModes
05 · From Timed Steps to Actions
  • Timed and Encoder Autonomous
  • Autonomous State Machines
  • Actions and Sequencing
06 · PID and Feedforward
  • PID Basics
  • Feedforward and PIDF
  • Dashboard Tuning Workflow
07 · Motion Profiling
  • Motion Profile Concepts
  • Implementing a Profiled Mechanism
  • Testing Profiles and Failure Modes
08 · OpenCV and AprilTags
  • VisionPortal Camera Setup
  • OpenCV Color and Region Processors
  • AprilTags and Field Pose
09 · Setup and Tuning
  • Road Runner 1.0 Install and Drive Class
  • Feedforward Tuning
  • Localization and Validation
10 · Trajectories, Actions, and MeepMeep
  • Action Builder and Trajectories
  • MeepMeep Preview
  • Full Road Runner Autonomous
11 · Git, Debugging, and Competition Readiness
  • Git Workflow for FTC Teams
  • Telemetry-First Debugging
  • Competition Readiness Checklist
12 · Driver Control
  • Driver Control
13 · Autonomous Build
  • Simple Autonomous
14 · Debugging
  • Debugging with Telemetry

02 / FTC Hardware Essentials

Hardware Map and RobotHardware

Build a reusable hardware class modeled after the attached RobotHardware template.

60 minCoreFTC Hardware Essentials

You will

  1. 01Map robot configuration names to Java fields.
  2. 02Set directions and zero-power behavior during init.
  3. 03Separate hardware setup from OpMode logic.

Why Hardware Map and RobotHardware matters

This lesson connects Java objects to real devices on the robot. The core idea is that configuration names, ports, directions, modes, and safe ranges are part of the code contract. If that contract is sloppy, every later TeleOp, autonomous, and control lesson becomes harder to trust.

Starting point

Configuration names are a contract

The Control Hub configuration and Java code must agree exactly. A central RobotHardware class makes that contract visible and keeps every OpMode from remapping the same devices differently.

Initialize once, then reuse

The attached template shows the right direction: motors, servos, IMU, hub modules, voltage, and subsystems are all initialized in one predictable place. Beginner teams can start with drivetrain only, then add mechanisms as needed.

Build path

Build from one device outward. Prove a motor, then a drivetrain, then a sensor, then a reusable hardware class. Each addition should have a test OpMode or telemetry checkpoint so students can identify whether the problem is code, configuration, wiring, or mechanism design.

For this specific lesson, students should first restate the goal in robot terms, then identify the value or behavior they expect to observe, then run the smallest test that proves the idea. The lesson should feel like a guided lab: predict, run, observe, explain, and only then extend.

RobotHardware.java · Java

public class RobotHardware {
    public DcMotorEx frontLeft, frontRight, backLeft, backRight;
    public List<LynxModule> hubs;

    public void init(HardwareMap hardwareMap) {
        frontLeft = hardwareMap.get(DcMotorEx.class, "front_left");
        frontRight = hardwareMap.get(DcMotorEx.class, "front_right");
        backLeft = hardwareMap.get(DcMotorEx.class, "back_left");
        backRight = hardwareMap.get(DcMotorEx.class, "back_right");

        frontLeft.setDirection(DcMotor.Direction.REVERSE);
        backLeft.setDirection(DcMotor.Direction.REVERSE);

        for (DcMotorEx motor : List.of(frontLeft, frontRight, backLeft, backRight)) {
            motor.setZeroPowerBehavior(DcMotor.ZeroPowerBehavior.BRAKE);
        }

        hubs = hardwareMap.getAll(LynxModule.class);
        for (LynxModule hub : hubs) {
            hub.setBulkCachingMode(LynxModule.BulkCachingMode.MANUAL);
        }
    }
}

Debugging and failure modes

Hardware bugs often masquerade as programming bugs. A wrong config name looks like bad Java, a reversed motor looks like bad math, and a noisy sensor looks like bad logic. Students should learn to isolate the physical device before changing higher-level robot behavior.

Practice

Create a drivetrain-only RobotHardware class for your current robot. Use the same hardware names in your robot configuration.

Checks

  • Every configured drivetrain motor has one matching Java field.
  • The left/right direction choices make forward power move forward.
  • Hub bulk caching is enabled for later sensor-heavy code.

Check your understanding

Module check

Why put hardware mapping in a RobotHardware class?

0 of 1 answered

References

FIRST FTC DocsOfficial FTC SDK and robot programming documentation.Game Manual 0Community FTC programming, control, and robot design reference.

Finished reading?

Mark this lesson complete.

You'll move on to “Motors, Servos, and Sensors” next.

Methods, Classes, and Robot HelpersMotors, Servos, and Sensors