#include "api.h" then use printf("motor temp: %f
", motor.temperature()); — output appears in the PROS terminal in VS Code when the robot is connected via USB.while(true){ printf("heading: %f
", imu.heading()); pros::delay(20); } — without the delay, the output floods faster than you can read it."heading: %f" not just "%f". When you are looking at a stream of numbers, labels are the difference between understanding and confusion.| Problem | What to Print |
|---|---|
| Auton drifts | imu.heading(), left and right motor velocity |
| Motor not moving | motor.temperature(), motor.current(), motor.get_port() |
| Sensor reading wrong | Raw sensor value + expected range every 50ms |
| PID not settling | Error, integral, derivative, and output each cycle |
| Code path not reached | Print a unique string at each branch: "branch A taken" |
Brain.Screen.setCursor(row, col); then Brain.Screen.print(value); — rows 1-8 fit on screen. Use one row per variable so output does not scroll.Brain.Screen.clearScreen(); at the top of your display loop prevents old values from overlapping new ones.pros::Task display_task(display_fn);Before debugging code, rule out hardware. Most "software bugs" in VRC are hardware faults in disguise.
| Error / Symptom | Cause | Fix |
|---|---|---|
ENODEV on motor/sensor | Wrong port number or cable not seated | Re-seat cable; verify port number in constants file matches physical port |
| Motor runs at full power non-stop | Motor voltage set instead of velocity; no control loop | Use motor.move_velocity(speed) not motor.move(127) for controlled motion |
| IMU always reads 0 | IMU not calibrated or on wrong port | Add imu.reset(); at startup and wait for calibration: while(imu.is_calibrating()) pros::delay(20); |
| Code compiles but nothing moves | Driver control task not started, or wrong competition state | Verify your opcontrol() function runs; check brain shows "Driver Control" not "Disabled" |
| Task crashes with stack overflow | Recursive function or very large stack allocation | Increase task stack size: pros::Task task(fn, nullptr, TASK_PRIORITY_DEFAULT, TASK_STACK_DEPTH_DEFAULT * 2, "Task"); |
| Auton runs in driver control | Competition switch or field control signal issue | Test with the PROS competition template; verify the brain receives field control signal |
undefined reference linker error | Function declared in header but not defined in any .cpp | Add the function body to the appropriate .cpp file; check for typos between declaration and definition |