RW 2.0
A VEX V5 autonomous template. The motion functions run whether or not you have tracking wheels, and everything sits on one reusable PID class.
What this is
RW 2.0 is a starting point for a VEX V5 competition program. You get a working chassis, a background odometry thread, and seven motion functions to call from your autonomous routine: driveTo, turnToAngle, swing, curveCircle, turnToPoint, moveToPoint, and boomerang.
Odometry is optional by design. With horizontal and vertical tracking wheels, the template reads both. With one, it reads that wheel plus the drivetrain encoders. With none, it falls back to the encoders and the inertial sensor, and the motion functions still work.
You write your routine in auton() and your driver controls in telop(), both in src/main.cpp. The tunables all live in src/robot-config.cpp.
Features
- Universal PID class
- One controller (
include/pid.h) runs the motion and heading work, and you can point it at your own subsystems. It clamps the integral, gates it by error range, and exits on a two-stage condition so movements settle instead of hunting. - Odometry that adapts to your hardware
- Two booleans pick one of four tracking modes at startup. A background thread updates position at 100 Hz.
- IMU heading correction
- A correction PID holds heading during straight moves and while the robot sits still, so a routine doesn’t drift sideways as it goes.
- Point and pose navigation
turnToPointandmoveToPointnavigate to field coordinates.boomerangdrives to a pose, meaning a coordinate plus a final heading, along a curved approach.- Curved paths without odometry
curveCircleruns a constant-radius arc on heading and distance PID alone, so it works on a robot with no tracking wheels.- Motion chaining
- Pass
exit = falseand the robot rolls into the next command instead of stopping. Routines built this way flow instead of stuttering. - Distance-sensor position resets
- Square up against a wall and call
resetPositionFront()(or back, left, right) to snap odometry back to the truth mid-routine. Use however many sensors you have. - Built-in PID autotuner
- Press Y on the controller and a Twiddle optimizer tunes the distance gains for you.
Where to go next
| Page | What’s in it |
|---|---|
| Getting Started | Install the toolchain, build, download to the brain, first drive test |
| Configuration | Every port, measurement, and tunable in robot-config.cpp |
| Tuning | The autotuner, then hand-tuning turns and heading correction |
| API Reference | Motion functions, odometry, and the PID class |
| Troubleshooting | Known limitations and common failure modes |
Before your first run
Every PID gain ships as
0. The template will not move the robot until you tune it. Set your ports and chassis measurements first, then work through Tuning. See Troubleshooting for the other known rough edges in the shipped config.
Credits
RW 2.0 is derived from richardbwang/RW-Template.