// project · 20 commits · March 2025, rebuilt November 2026
Drives a small robot to its goals in simulation, steering around the obstacles its laser scanner sees.
8 of 8waypoints reached in Gazebo, with every planner
C++ node on a simulated TurtleBot3, no collisions, never closer than 0.15 m to an obstacle
Replays of recorded Gazebo runs and benchmark results. Simulation only, never run on a real robot.
8 / 8
waypoints
0.17 m
closest pass
10 to 12x
C++ vs Python
The robot reacts to what its laser scanner sees right now. It has no map and plans no route, so it can drive around pillars and out of small dead ends but could not solve a maze. The same navigation code exists twice: in C++, the version the robot runs, and in Python, the reference the C++ version is checked against. Everything here ran in simulation, in Gazebo and in a lightweight 2D simulator, never on a physical robot.
Eight waypoints weaving between the pillars and around the arena. The line is the robot's own odometry. Switch planner or node to see each recorded run.
Finished: 8 of 8 waypoints in 84.2 s of simulated time, 17.1 m driven. Closest pass is the gap between the robot's edge and any pillar or wall over the whole run.


The arena plus four random extra pillars, a random start and a goal at least 2.5 m away, 90 seconds allowed. Every planner gets the same 50 scenarios, chosen after all the fixes were done. The C++ and Python planners give the same result in every single run. Path efficiency is the straight-line distance divided by the distance driven.
| Planner | Goals reached | Collisions | Time to goal | Path efficiency | Closest pass |
|---|---|---|---|---|---|
| Sector | 100% | 0% | 24.7 s | 0.92 | 0.16 m |
| Potential field | 100% | 0% | 25.2 s | 0.96 | 0.17 m |
| Follow the gap | 100% | 0% | 34.4 s | 0.85 | 0.13 m |
| Planner | Goals reached | Collisions | Time to goal | Path efficiency | Closest pass |
|---|---|---|---|---|---|
| Sector | 100% | 0% | 25.7 s | 0.89 | 0.17 m |
| Potential field | 100% | 0% | 23.3 s | 0.98 | 0.18 m |
| Follow the gap | 96% | 0% | 30.8 s | 0.88 | 0.14 m |
Goals reached on the development scenarios before and after each fix.
Potential field
54% → 80%
Problem. Never reached a goal next to a wall: the wall pushed as hard as the goal pulled, so the robot circled about 0.4 m away.
Fix. Fade the push near the goal (Ge and Cui, 2000) and ignore obstacles farther away than the goal.
Potential field
80% → 100%
Problem. One push per laser beam, so a wall that filled more beams pushed harder; the total often pointed backwards.
Fix. Weight each beam by its angle, so the push no longer depends on the scanner resolution.
Follow the gap
46% → 96%
Problem. Always took the widest opening, even when it led away from the goal, so the robot wandered.
Fix. Take the opening closest to the goal direction and aim at its point nearest the goal.
Microseconds per laser scan (1,000 µs = 1 ms), median. Lower is better.
step 1
Five times a second the robot gets a 360-beam laser scan. Missing or out-of-range readings are cleaned up, and the free space is measured in five directions from right to left.
step 2
Odometry gives the robot its position, so it knows the distance and direction to the next waypoint. Goals come from a list or from a click in RViz.
step 3
One of three planners turns the scan and the goal into a speed and a turn rate: free-space sectors, a potential field where the goal pulls and obstacles push, or steering into the opening closest to the goal.
step 4
The robot slows down near obstacles. If it stays blocked it backs out, but only if nothing is behind it, and if it makes no progress toward the goal it follows the wall out of the trap.
// tap a step to see what it does
3/6 PlannerThe core step. Sector: speed falls with clearance and the robot turns to the more open side, with a dead band so it does not flip left and right. Potential field: the goal pulls, obstacles push. Follow the gap: steer into the opening closest to the goal.
| What | Result | Compared with |
|---|---|---|
| Waypoints reached on the 8-point Gazebo tour, C++ node | 8 of 8, every planner | 84 to 87 s of simulated time and 17.1 to 17.4 m driven per tour |
| Closest the robot's edge came to a pillar or wall | 0.15 to 0.17 m | Same Gazebo tours. No collisions in Gazebo or in any benchmark run |
| Goals reached in 50 random scenarios the planners were never tuned on | 100% | All three planners, with the C++ and the Python planner alike |
| C++ planner time per laser scan, median | 0.11 to 0.17 ms | Python reference 1.1 to 2.0 ms, so 10 to 12 times faster. A new scan arrives every 200 ms |
| C++ against Python decisions | identical | Within 1e-9 on every step of 30 closed-loop runs, and trial for trial on the 50-scenario benchmark |
| Potential-field planner after two fixes found by the benchmark | 54% to 100% | Goals reached on the development scenarios, the ones used while fixing it, so not a held-out number |
Sources: the project README and its results folder: the recorded Gazebo runs (results/web/gazebo_tour.json), the benchmark tables and the timing table. Gazebo runs were recorded headless in Docker on a laptop under WSL2.
Stack. ROS 2 Humble, C++17 (rclcpp, ament_cmake) and Python 3.10 (rclpy, ament_python), Gazebo 11 with the TurtleBot3 Burger model, RViz2, pybind11, GoogleTest, pytest, Docker, GitHub Actions.
Two implementations. The planner is a ROS-free C++ library linked into the rclcpp node, the GoogleTest suite and a pybind11 module. The rclpy node and its planner are the reference. A parity test drives 30 runs in the 2D simulator and feeds every scan to both planners: speed, turn rate, state and all sector distances must agree within 1e-9 on every step, including the stateful recovery and trap logic. The port keeps Python's tie-breaking and rounding so this holds.
Potential field. Repulsion follows Khatib's (1/d - 1/d0)/d², with 15% of it turned sideways so an obstacle dead ahead cannot cancel the goal. Near the goal it is scaled by (d_goal/d0)², and obstacles farther away than the goal are skipped. Each beam is weighted by the angle between beams, so the force is an integral over the field of view and does not grow with scanner resolution.
Node. Goals from RViz's 2D Goal Pose or a waypoint list, holds position after the last one. Parameters are validated on every change (unknown planners and inverted thresholds are rejected; topic names are read-only). A scan watchdog stops the robot, and the C++ node sends a zero velocity from a pre-shutdown callback on Ctrl-C, while ROS can still publish. RViz markers show free space per direction, heading, safety ring, goals and the travelled path.
Evaluation. A 2D simulator reads the obstacles from the Gazebo world file, so the benchmark and Gazebo share one arena. Scenarios are seeded and identical for every planner. The fixes were made on one set of scenarios (seed 7) and checked once on a new set (seed 2026).
CI. colcon builds and tests both packages in a ros:humble-ros-base container: 26 Python unit tests, 16 GoogleTest cases, the parity test, and the ROS linters (flake8, pep257, cpplint, uncrustify, lint_cmake, xmllint). The C++ code builds with -Wall -Wextra -Wpedantic -Werror. Every run posts benchmark tables for both implementations.
Limits. Purely reactive, with no map or global planner. Simulation only. The 2D simulator has no inertia, wheel slip or sensor noise, so it compares planners with each other and Gazebo is the physics check. The nodes' ROS wiring is tested in Gazebo rather than by node-level tests.