WestlakeLEARN
FTC · Java

FIRST Tech Challenge

FTC · Java

  • LinearOpMode Lifecycle
  • Telemetry as Instrumentation
  • Hardware Map and Motors
  • Gamepad Input and Edge Detection

Hardware Map and Motors

Connect configuration names to Java objects safely.

Module 2: FTC SDK FoundationsCore

In this lesson, you will:

  1. 01Match code names to Robot Controller configuration names.
  2. 02Set motor direction intentionally.
  3. 03Use low power while testing on blocks.

The hardware map is a lookup table

The Robot Controller app stores names for motors, servos, and sensors. Java code asks the hardware map for those names, then controls the returned objects.

Names are part of the code contract

If the config says frontLeft but the code asks for leftFront, the robot will not initialize. Keep names boring, consistent, and written down.

Direction depends on how the motor is mounted

Motors on opposite sides of many drivetrains are mounted as mirror images, so the same positive power can spin their wheels in opposite robot-relative directions. Reverse whichever side your physical build requires, then verify it on blocks. The goal is simple: positive power should mean robot-forward on every drive motor.

Robot code habit

Keep one shared list of configuration names and use the same spelling and capitalization in robot configuration and code.

On-robot safety

Put the robot on blocks and pulse one motor at low power at a time until every direction is verified.

DriveHardware.javaJava

DcMotor frontLeft = hardwareMap.get(DcMotor.class, "frontLeft");
DcMotor frontRight = hardwareMap.get(DcMotor.class, "frontRight");
DcMotor backLeft = hardwareMap.get(DcMotor.class, "backLeft");
DcMotor backRight = hardwareMap.get(DcMotor.class, "backRight");

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

waitForStart();

// Robot on blocks: test one wheel, then return it to zero.
if (opModeIsActive()) {
  frontLeft.setPower(0.2);
  sleep(500);
  frontLeft.setPower(0.0);
}

Practice

Put the robot securely on blocks. Map all four drivetrain motors, then pulse one motor at a time at 20 percent power for half a second and return it to zero before testing the next motor.

Checks

  • The robot initializes without hardware errors.
  • Each configuration name controls exactly one expected wheel.
  • Every pulse returns to zero before the next motor test begins.
  • Positive power makes all four wheels agree on robot-forward.

Lesson check

Check your understanding before moving on.

The string in hardwareMap.get(DcMotor.class, "frontLeft") must match what exactly?

Why is one side of the drivetrain usually set to REVERSE?

0 of 2 answered

References

FTC DocsOfficial FTC SDK and robot programming documentation.Road Runner 1.0 DocsCurrent official setup guide. Confirm TeamCode's Gradle versions first; 1.0 is not compatible with 0.5.x examples.

Finished reading?

Mark this lesson complete — “Gamepad Input and Edge Detection” is up next.

Telemetry as InstrumentationGamepad Input and Edge Detection