Three single-motion exercises that build on each other. By the end, your robot drives a 2-foot square on its own — and you'll see exactly why competition autons need sensors.
chassis object configured with your motor ports, gear ratio, and wheel size.
If you're new to PROS and EZ Template, do these three exercises first. When all three work, graduate to Clawbot Training — which combines drive and turn from the very first exercise and assumes you understand both.
chassis object set up with your motor ports, gear ratio, and wheel sizechassis object has the wrong wheel size or gear ratio, every distance will be off by exactly that ratio. The robot will look like it's working — it'll just always stop short, or always overshoot. The EZ Setup guide has a chassis-constructor builder that does the math for you.All three exercises are void functions that live in src/autons.cpp. To run one, call it from inside the autonomous() function in src/main.cpp. For example:
Whichever exercise you're testing, that's the one line that goes inside autonomous(). Swap it out as you move through the three exercises.
24_in — drive 24 inches forward. Use a negative number to go backward.80 — speed out of 127. EZ-Template's standard starting point for drive.pid_wait() — pause the auton until the robot finishes the move. Without it, the next command queues immediately and the robot won't finish the previous move. This is the most common beginner bug.drive_forward_24() from inside autonomous(), then disable + enable the robot (or use the auton selector) to trigger it. Don't worry yet if it stops short or overshoots — that's tuning, which we do at the end. Right now we're just confirming the function compiles, uploads, and moves the robot.autonomous(), or the brain isn't actually in autonomous mode. Check the auton selector or competition switch.chassis constructor.chassis constructor. Measure carefully.pid_turn_set instead of pid_drive_set. Different function, different PID constants under the hood — turn PID and drive PID get tuned separately.90_deg with the _deg suffix (not _in). Negative degrees turn counter-clockwise (left).70 instead of 80. Turns usually run a bit slower than drives because there's less momentum to overcome — this is the standard EZ-Template starting point.drive_forward_24() for turn_right_90() in autonomous(), upload, run. The robot will probably overshoot or undershoot the 90°. That's expected — we'll tune turn PID at the end alongside drive PID.chassis constructor. EZ-Template uses the IMU's heading reading; if it's mounted upside-down or sideways, "right" can become "left."This is just Exercise 1 and Exercise 2 inside a loop. Four sides, four turns:
What's happening:
What to notice: a tight loop reveals PID error. If each turn under-rotates by 1°, four turns accumulate to 4° of heading error and the square spirals outward. The end-position miss tells you whether your turn PID is biased. Tune kP/kD in the turn PID until the error spread across 5 runs is under 2″.
Tune order: kP first, then kD, then kI only if you have steady-state error. Tune drive first, then turn. Touch one constant at a time. Re-run Exercise 3 after each round — the square will get tighter as your constants get better.
Tuned PID gets you within about half an inch on a 24″ move and a couple of degrees on a 90° turn. Once you've squeezed all you can out of PID and the square still drifts noticeably, it's time for closed-loop sensing: