Most EZ-Template work is just 4-5 functions. This decision tree maps "what I want to do" to the right function call.
flowchart TD
Start([What do you
want the bot to do?]) --> Q1{Drive or turn?}
Q1 -->|"Drive straight"| Drive[chassis.pid_drive_set
distance, max_speed, slew_on]
Q1 -->|"Turn in place"| Turn[chassis.pid_turn_set
angle_deg, max_speed]
Q1 -->|"Drive while turning"| Swing[chassis.pid_swing_set
angle, max_speed, type]
Q1 -->|"Joystick driving"| Op[chassis.opcontrol_arcade_standard
ez::SPLIT or ez::SINGLE]
Drive --> Wait[Then: chassis.pid_wait
blocks until exit condition met]
Turn --> Wait
Swing --> Wait
Op --> Loop[Inside while loop
plus pros::delay]
Wait --> Next([Move to next step])
Loop --> Next
style Start fill:#1e293b,stroke:#22d3ee,stroke-width:2px,color:#e2e8f0
style Q1 fill:#fbbf24,color:#0f172a,stroke:#fbbf24
Keep this open while coding. Functions, configs, common errors, and fix patterns β all in one place.
// target inches, max speed (0-127) chassis.pid_drive_set(24, 110); chassis.pid_wait();
// target degrees (0=forward, 90=right) chassis.pid_turn_set(90, 90); chassis.pid_wait();
// e2e::LEFT_SWING or RIGHT_SWING chassis.pid_swing_set( ez::LEFT_SWING, 45, 90); chassis.pid_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();
// 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_ms, 3_deg, 300_ms, 7_deg, 500_ms, 500_ms); chassis.pid_drive_exit_condition_set(80_ms, 50_mm, 300_ms, 150_mm, 500_ms, 500_ms); }
// 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
// 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), });
\n to add a second line. Button 1/2 on the controller cycles autons.pid_drive_set() or pid_turn_set() needs a matching chassis.pid_wait(); on the next line β unless you explicitly want to chain.#include "globals.hpp" at the top of the file where you're calling chassis functions. It's defined there, not in main.cpp.autons_add() must match exactly. Also confirm you're calling ez::as::initialize(); inside initialize() before the selector runs.| Function | What it does | Notes |
|---|---|---|
| pid_drive_set(in, spd) | Drive forward/backward in inches | Negative inches = reverse |
| pid_turn_set(deg, spd) | Turn to an absolute heading | 0=forward, 90=right, -90=left |
| pid_swing_set(side, deg, spd) | Arc turn on one side | e2e::LEFT_SWING or RIGHT_SWING |
| pid_wait() | Block until movement completes | Required after every movement |
| pid_wait_until(in) | Continue after reaching distance | Use for mid-move triggers |
| pid_wait_quick_chain() | Chain next movement smoothly | Reduces settling time |
| chassis.drive_set(l, r) | Raw tank drive (-127 to 127) | Use in opcontrol, not auton |
| pros::delay(ms) | Wait in milliseconds | Use sparingly β prefer pid_wait |