Tutorial 19: Testing procedures
You will build: a 3-line OpMode that lets you test every motor, servo and sensor on the robot by hand. This is also lesson 2b of the main track (after lesson 2, Drive).
You will learn: how to use the Hardware Check OpMode, a fixed order for testing a robot (laptop, bench, floor, autonomous, event), and how to turn a problem into a fix that stays fixed.
You need: any robot. Tutorials 01-03.
Full program: Tut19HardwareCheck.java (yes, it is 3 lines)
Reference: testing.md. Guide with all checklists: Testing procedures.
1. The 3-line OpMode
Section titled “1. The 3-line OpMode”The OpMode itself is 3 lines. With the lines every Java file needs, the whole file is this. Make a
new Java file HardwareCheck.java in your teamcode folder
(how to make a file), and replace everything in it
with:
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.eventloop.opmode.TeleOp;import com.crossbotics.ftchelper.testing.HardwareCheckOpMode;
@TeleOp(name = "Hardware Check", group = "Tests")public class HardwareCheck extends HardwareCheckOpMode {}- File name:
HardwareCheck.java, the same as the class name afterpublic class. - The
packageline says the file is in theteamcodefolder. - The two
importlines say whereTeleOp(from the FTC SDK) andHardwareCheckOpMode(from this library) are. Why: without them, the build sayscannot find symbol. - No
@Disabledline: the Driver Station lists it.
extends means “is a kind of”: this OpMode is a HardwareCheckOpMode, so it does everything that
class does. The library wrote the OpMode; you only give it a name. (The tutorial’s own copy is named
“Tutorial 19: Hardware Check”; the name in @TeleOp(name = ...) can be anything.)
2. Use it
Section titled “2. Use it”Put the robot on a block, so the wheels are off the ground. Run it. It lists every device in the active configuration and the battery voltage.
- D-pad up/down: choose a device. Changing device stops the last motor.
- Motor: right stick = power (50% max; hold RB for 100%). Watch: does positive power turn it the way you expect? Does the encoder count UP? A = zero the encoder.
- Servo: D-pad right/left = +/- 0.01, bumpers +/- 0.1, X = 0.5. Write down the positions you need.
- Sensors: live values. Press the switch, wave a hand at the distance sensor.
- IMU: turn the robot left by hand: yaw goes UP (if your hub is mounted logo up, USB forward).
3. A fixed order
Section titled “3. A fixed order”flowchart LR
A["laptop tests"] --> B["Hardware Check<br/>(on a block)"] --> C["mechanism checks"] --> D["floor, low power"] --> E["autonomous runs<br/>read the report"]
Do the steps in this order. Each step catches problems the next one would make dangerous or confusing. Example: a reversed drive motor (found in seconds at step B) looks like “the robot spins randomly” at step D.
The full checklists, including the 2-minute pre-match check, are in Testing procedures. Print them for the pit.
4. When something breaks
Section titled “4. When something breaks”- Write it down: what you did, what you expected, what happened. Turn debug telemetry on and take a photo of the screen.
- Reproduce it on the bench. A problem you cannot repeat cannot be fixed on purpose.
- Find the layer (where the problem lives): hardware (Hardware Check shows it)? configuration (names)? your code? the library?
- Fix it and add a test if it was logic (tutorial 13), so it can never come back silently.
- Note it in the team’s log: the next driver or programmer will meet it again.
Run it
Section titled “Run it”- Make the file from section 1 in TeamCode (the whole file, with its
packageandimportlines), build, install and run it. - Go through every device once. Fix any direction or name problem you find.
- Take the pre-match checklist from the guide and time yourself: it should take about 2 minutes.
Try this
Section titled “Try this”- Make your own OpMode that runs every drive motor forward for 1 second in turn, and shows its encoder change.
- Write a test (tutorial 13) for something that once went wrong on your robot.
You finished the tutorials
Section titled “You finished the tutorials”On the main track, next: Lesson 3: Buttons. Under the hood: Tutorial 20: Easy TeleOp, 21: Find your numbers, and Lesson 1: The robot in five files, the shortest way to a whole robot program. Extending the library when you build something new.