← Back to Home · Back to Programming

Programming · Common Code Mistakes

Fix the classic FTC code pitfalls

Avoid blocking, missing waits, encoder misuse, and bad init that burn matches.

What this is

  • Checklist of frequent code errors that break robots.
  • Why they happen and how to prevent them.
  • Quick tests to catch them before events.

When you need it

  • New programmers joining mid-season.
  • Robot freezes, won’t start, or ignores inputs.
  • Autos or TeleOps behave differently in matches vs practice.

How it works

  • Blocking loops: avoid while-loops in LinearOpMode without yields; use opModeIsActive() and small sleeps.
  • waitForStart(): always call before main loop; avoid work that drives motors before start.
  • Encoders: reset when needed; keep consistent direction; convert ticks↔distance correctly.
  • Init: hardwareMap names must match config; guard sensors that may be absent; handle nulls.

Common mistakes

  • Infinite loops without opModeIsActive() checks.
  • Driving motors before start in init loop.
  • Wrong ticks-per-rev or wheel diameter causing drift.
  • Forgetting to set motor direction or zero power behavior.

How to test it

  • Step through auto with low power; verify loop exits when !opModeIsActive().
  • Check motor power is zero before start; watch telemetry in init.
  • Drive a measured distance and compare ticks to expected.
  • Toggle zero power behavior (BRAKE/COAST) and confirm expected motion.

Related problems

  • Robot won’t stop → missing opModeIsActive() checks or timeouts.
  • Strange headings → mixed motor directions or encoder signs.
  • Start-line penalties → motors moving during init; ensure powers zeroed.