I wanted to see if I could train a two-wheel robot to drive to a waypoint without writing the steering rules myself. In DiffDriveRL, I use PPO to train a policy that controls the left and right wheels separately on a 144-inch-square simulated VEX field.
Watch the training clip and read the project write-up · Play or download the MP4
At first, the robot kept circling the waypoint instead of driving into it. I’d made being near the target worth too much, so the robot could score well without getting where I wanted it to go. I changed the reward to give it more credit for making progress toward the waypoint. I also added training stages for driving through multiple waypoints, arriving at a certain angle, getting around obstacles, and recovering near walls.
The clip shows one run in simulation. I haven’t tested this policy on a physical robot.
Use an isolated Python environment with a supported PyTorch install for your machine. From the repository root:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install gymnasium numpy pygame torch skrlPlay back the included checkpoint in the Pygame viewer:
python replay.py --checkpoint runs/replay/latest.ptClick to choose a waypoint, press R for a random reset, or Esc to exit. To evaluate without opening the viewer:
python eval.py --checkpoint runs/replay/latest.pt --episodes 64Train a separate candidate without overwriting the included checkpoint:
python train_ppo.py --headless --profile heading_bridge_tune \
--timesteps 100000 --output runs/replay/heading_waypoint_candidate.pt
python gate_candidate.py --baseline runs/replay/latest.pt \
--candidate runs/replay/heading_waypoint_candidate.pt --episodes 32The gate compares the candidate and baseline before any checkpoint is promoted. Use --help on those scripts to see all scenarios and options.
| File | Start here for |
|---|---|
env.py |
Gymnasium environment, robot movement, observations, and rewards |
train_ppo.py |
skrl PPO model, training profiles, and checkpoints |
eval.py / gate_candidate.py |
Evaluating a policy and comparing it to the replay baseline |
replay_app.py |
Interactive playback and waypoint controls |
I developed this through Paideia’s Professional Immersions program. Thanks to Daniel Berlin for mentoring me. I used Gymnasium, skrl, PyTorch, and Pygame.
