๐Ÿ’ป Programming ยท Quick Reference ยท All Levels

EZ Template Quick Reference

Keep this open while coding. Functions, configs, common errors, and fix patterns โ€” all in one place.

๐Ÿš— Chassis Functions
Drive straight
// target inches, max speed (0-127)
chassis.pid_drive_set(24, 110);
chassis.pid_wait();
Turn to heading
// target degrees (0=forward, 90=right)
chassis.pid_turn_set(90, 90);
chassis.pid_wait();
Swing turn (one side)
// e2e::LEFT_SWING or RIGHT_SWING
chassis.pid_swing_set(
  ez::LEFT_SWING, 45, 90);
chassis.pid_wait();
Chained movement (no wait)
// Start next move before fully stopped
chassis.pid_drive_set(12, 110);
chassis.pid_wait_quick_chain();
chassis.pid_turn_set(-45, 90);
chassis.pid_wait();
โš™ PID Constants Location
// In src/autons.cpp โ€” default_constants() function
void default_constants() {
  chassis.pid_drive_constants_set(20, 0, 100);  // kP, kI, kD
  chassis.pid_heading_constants_set(11, 0, 20); // keeps drive straight
  chassis.pid_turn_constants_set(3, 0.05, 20);  // kP, kI, kD
  chassis.pid_swing_constants_set(6, 0, 65);    // kP, kI, kD
  chassis.pid_turn_exit_condition_set(80, 50, 300, 150, 500, 500);
  chassis.pid_drive_exit_condition_set(80, 50, 300, 150, 500, 500);
}
๐Ÿ”Œ Sensor Configuration (globals.hpp)
// in include/globals.hpp
// Motors: positive port = forward, negative = reversed
ez::Drive chassis ({-1, -2, -3},    // left motors
                   {4, 5, 6},     // right motors
                   7,             // IMU port
                   3.25, 1, 360); // wheel diam, gear ratio, ticks/rev

// Common gear ratios:
// 600rpm motor, 36:48 gearing โ†’ ratio = 36.0/48.0 = 0.75
// 600rpm motor, direct drive  โ†’ ratio = 1
๐Ÿ“ก Auton Selector Setup
// in src/main.cpp โ†’ initialize()
ez::as::auton_selector.autons_add({
  Auton("Drive Forward\n15pt auton", drive_forward),
  Auton("Left Side\n8pt safe",   left_auton),
  Auton("Skills Run\n90sec",     skills),
});
The first string is the Brain display name. Use \n to add a second line. Button 1/2 on the controller cycles autons.
โšก Top 5 Beginner Errors
โŒ Robot skips pid_wait() and runs movements out of order
Fix: Every pid_drive_set() or pid_turn_set() needs a matching chassis.pid_wait(); on the next line โ€” unless you explicitly want to chain.
โŒ "Cannot find identifier chassis" compile error
Fix: Add #include "globals.hpp" at the top of the file where you're calling chassis functions. It's defined there, not in main.cpp.
โŒ Robot drives the wrong distance after a turn
Fix: Your tracking wheel diameter or gear ratio in the Drive constructor is wrong. Measure your wheel with calipers. Common mistake: using 4.0 for a 3.25" wheel.
โŒ Auton selector shows but nothing happens when robot starts
Fix: Your auton function names in autons_add() must match exactly. Also confirm you're calling ez::as::initialize(); inside initialize() before the selector runs.
โŒ IMU calibration takes forever or never finishes
Fix: IMU must be completely still during calibration. Don't touch the robot after uploading until the Brain says "Calibrated." Also verify the port number matches your physical wiring.
๐Ÿ“‹ Common Function Reference
FunctionWhat it doesNotes
pid_drive_set(in, spd)Drive forward/backward in inchesNegative inches = reverse
pid_turn_set(deg, spd)Turn to an absolute heading0=forward, 90=right, -90=left
pid_swing_set(side, deg, spd)Arc turn on one sidee2e::LEFT_SWING or RIGHT_SWING
pid_wait()Block until movement completesRequired after every movement
pid_wait_until(in)Continue after reaching distanceUse for mid-move triggers
pid_wait_quick_chain()Chain next movement smoothlyReduces settling time
chassis.drive_set(l, r)Raw tank drive (-127 to 127)Use in opcontrol, not auton
pros::delay(ms)Wait in millisecondsUse sparingly โ€” prefer pid_wait
⚙ STEM Highlight Computer Science: API Design & Abstraction Layers
EZ Template is an abstraction layer — a software engineering pattern that hides complex implementation details behind a simplified interface. The API defines what functions exist and what they do without exposing how they work internally. This is the same design principle used in operating systems, graphics APIs, and all modern software frameworks.
🎤 Interview line: “We treat the EZ Template documentation as an engineering specification, not a tutorial. Before writing any autonomous code, we read the API reference for every function we plan to use. Understanding pid_wait() versus pid_wait_until() at the API level prevented three auton failures that would have occurred if we had just copied example code.”
Your autonomous needs to wait for the robot to finish a turn before the next movement. Which EZ Template call is correct?
⬛ chassis.turn_angle(90, 110)
⬛ chassis.pid_wait()
⬛ delay(500)
📝
Notebook entry tip: Build & Program — Orange slide — Use this reference as the basis for your programming architecture entry: document which EZ Template functions your autonomous uses, why you chose pid_wait over pid_wait_until for each movement, and your final chassis constants. A programming entry that cites specific API functions shows judges your team understood the tools they were using — not just copied code.
← ALL GUIDES