Skip to content

About

A* vs RRT* on identical maps, with animated search and path-length benchmarks

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

motion-planning-visualizer

Side-by-side comparison of two classic motion planners on the same 2D map: A* on a grid and RRT* in continuous space. Produces an animated GIF of both searches running, plus a stats table.

A* vs RRT* on the corridors map

What this demonstrates: graph search vs sampling-based planning, admissible heuristics, RRT* choose-parent and rewire steps, and how to benchmark planners fairly on identical maps.

Quick start

python compare.py                      # corridors map
python compare.py --map cluttered
python compare.py --map bugtrap --iters 4000

Requires numpy and matplotlib. Each run prints a stats table and writes comparison_<map>.gif.

Sample results

Workspace is 100 x 100. Same start, goal, and obstacles for both planners.

Map Planner Path length Nodes Time
corridors A* 218.3 6156 18 ms
corridors RRT* 242.0 1874 72 ms
cluttered A* 129.6 3920 14 ms
cluttered RRT* 143.8 1794 75 ms
bugtrap A* 108.2 4986 15 ms
bugtrap RRT* 120.3 3017 137 ms

What the comparison shows

A* wins on this problem, and it should. The workspace is small, 2D, and easy to discretize. A* with an octile heuristic is complete and optimal on the grid: it finds the shortest grid path every time, in milliseconds. Its path is 6 to 11 percent shorter than RRT*'s on every map here.

RRT* pays a price for generality. It samples randomly, so its finite-budget path is jagged and suboptimal. It is only probabilistically complete: given infinite samples it finds a path, and given infinite samples its path converges to optimal (asymptotic optimality). You can see this in the animation: the tree keeps rewiring and the path keeps improving as samples accumulate.

So why does RRT* exist? Because A*'s grid does not scale. Grid cells grow exponentially with dimension, so a 7-DOF arm or a 22-DOF biped cannot be gridded. RRT* only ever needs to sample, steer, and collision-check, all of which stay cheap in high dimensions. This 2D demo is the one setting where you can watch both run on the same problem and see exactly what each one trades away.

The bugtrap map makes the contrast sharpest: A* flows around the trap and straight in through the opening, while RRT* has to stumble into the entrance by chance, which is why its node count doubles there.

A* vs RRT* on the bugtrap map

Layout

maps.py       obstacle presets (add your own layout here) and collision checks
astar.py      A* on a unit grid, octile heuristic, expansion history for the animation
rrt_star.py   RRT* with choose-parent and rewire, tree snapshots for the animation
compare.py    runs both, prints stats, renders the side-by-side GIF

Swapping maps: add an entry to MAPS in maps.py with a start, a goal, and a list of rectangles. Both planners pick it up automatically.

About

A* vs RRT* on identical maps, with animated search and path-length benchmarks

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages