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, 50, 300, 150, 500, 500); chassis.pid_drive_exit_condition_set(80, 50, 300, 150, 500, 500); }
// 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 |