Veralogiq · FTC Launchpad

FTC Launchpad · Programming

Programming walkthrough

Configure first OpModes Driver + robot

Terms for this walkthrough

  • Configuration — device names + ports on the robot; code must match.
  • OpMode — one runnable program (tele-op, auto, test).
  • Init vs loop — setup once, then repeat while the OpMode runs.
  • Telemetry — values on the driver station for debugging.

Step A — Physical setup before code

Step B — Blocks path (beginner-friendly)

What to build first

  1. Open the Blocks editor from the programming tools (see FTC Docs).
  2. Create a new OpMode — name it like TeleOp_Basic.
  3. In the loop: read a gamepad stick (e.g. left stick Y).
  4. Map that value to motor power for one side of the drivetrain (power is usually −1.0 to 1.0).
  5. Add telemetry to print the stick value so you can see it change.
  6. Run on the robot with a mentor—wheels should respond slowly at first.

Tip: get one motor turning correctly before wiring up all four.

Full Blocks walkthrough: FTC Docs — Blocks tutorial (also linked from Code + build).

Step C — Java path (OnBot or Android Studio)

Big picture

  • Your OpMode is a class that extends something like LinearOpMode.
  • hardwareMap — look up devices by the names from configuration.
  • runOpMode() — your main method: wait for start, loop in tele-op, etc.

Pseudo-structure (don’t copy blindly—learn with a mentor)

// After hardware is configured with names "left_drive", "right_drive":
// In runOpMode():
//   waitForStart();
//   while (opModeIsActive()) {
//     double drive = -gamepad1.left_stick_y;
//     left_drive.setPower(drive);
//     right_drive.setPower(drive);
//     telemetry.addData("stick", drive);
//     telemetry.update();
//   }

Tutorials: OnBot Java · Android Studio (also on Code + build).

Step D — Autonomous (next skill)

Step E — Debug like a programmer

Localization & sensors

Knowing where your robot is on the field makes autonomous reliable. Sensors feed that information to your code.

Common FTC sensors

  • IMU (Inertial Measurement Unit) — built into the Control Hub. Measures rotation (heading/yaw). Used to drive straight and for field-centric control.
  • Encoder — built into most FTC motors. Counts shaft rotations so you know exactly how far a wheel or mechanism moved.
  • Color sensor — detects surface color or reflected light. Used to detect field elements, line-follow, or detect game piece presence.
  • Distance sensor (ToF) — time-of-flight laser. Measures distance to walls or game elements; useful for alignment.
  • Camera / AprilTag — FTC uses AprilTag markers on field elements. The SDK has built-in vision processors so you can read tag ID and estimate robot pose without external libraries.

Dead reckoning with encoders

Track (odometry) your position by counting encoder ticks:

  • Measure your wheel circumference (diameter × π).
  • Know your encoder ticks-per-revolution (check motor datasheet — often 537.7 PPR for goBILDA 312 RPM).
  • Distance traveled = (ticks / PPR) × circumference.
  • Works well on smooth surfaces; accumulates error over time — reset at known field landmarks.

AprilTag localization (FTC SDK)

  • The FTC SDK (v8.2+) includes AprilTagProcessor — no extra libraries needed.
  • Returns a AprilTagDetection with ftcPose: x, y, z offsets and bearing to the tag.
  • Cross-reference tag ID (from Game Manual) with its known field position to get absolute robot position.
  • Use this to correct accumulated odometry drift when you drive past a tag — the vision measurement resets your position estimate.
IMU-assisted straight drive (code sketch)
// keep robot pointed at target heading while driving
double targetHeading = 0; // degrees
while (opModeIsActive() && !isAtTarget()) {
  double error = targetHeading - imu.getZAngle();
  double correction = error * 0.02; // tune Kp
  leftPower  = DRIVE_SPEED + correction;
  rightPower = DRIVE_SPEED - correction;
  setMotors(leftPower, rightPower);
  telemetry.addData("Heading error", error);
  telemetry.update();
}

This is a simple P-controller. You'll tune Kp by running the robot and observing drift.

Your programming checklist

Official references

Programming concepts (loops, logic): see Code + build and GM0 fundamentals.

  • Always follow safety rules — they exist to protect people and equipment.
  • Your lead programmer / coach approves what runs at competition.
← CAD Programming For parents →