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 Essentials2/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

Motors, Servos, and Sensors

Control common FTC devices safely and read useful sensor values.

60 minCoreFTC Hardware Essentials

You will

  1. 01Command motors and servos with safe ranges.
  2. 02Read encoders, distance, and color values.
  3. 03Create testing OpModes for one device at a time.

Why Motors, Servos, and Sensors 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

Test one device before testing the robot

A mechanism OpMode that only moves one motor or servo is not wasted time. It proves the configuration, direction, range, and safety limits before the mechanism enters match code.

Sensors are inputs, not magic

Distance and color sensors should be printed to telemetry first. Once students trust the readings, those values can drive decisions such as stopping before a wall or detecting a game element.

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.

SensorStop.java · Java

DistanceSensor distance = hardwareMap.get(DistanceSensor.class, "front_distance");

while (opModeIsActive()) {
    double cm = distance.getDistance(DistanceUnit.CM);
    boolean tooClose = cm < 5.0;

    robot.frontLeft.setPower(tooClose ? -0.15 : 0.20);
    robot.frontRight.setPower(tooClose ? -0.15 : 0.20);

    telemetry.addData("Distance cm", cm);
    telemetry.addData("Too close", tooClose);
    telemetry.update();
}

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

Write the slide-deck refresher challenge: drive forward until a distance sensor reads less than 5 cm, then back away slowly.

Checks

  • The robot is tested on blocks before touching the floor.
  • Telemetry shows the sensor value used by the decision.
  • The robot has a clear stop or reverse condition.

Check your understanding

Module check

What should you do before using a sensor value to control motion?

0 of 1 answered

References

FIRST FTC DocsOfficial FTC SDK and robot programming documentation.Game Manual 0Community FTC programming, control, and robot design reference.Learn Java for FTCFTC-focused Java fundamentals by Alan G. Smith.

Finished reading?

Mark this lesson complete.

You'll move on to “IMU, Encoders, and Bulk Caching” next.

Hardware Map and RobotHardwareIMU, Encoders, and Bulk Caching