RRT Path Planning

PythonNumPyMatplotlibMotion Planning

Overview

RRT Path Planning is a real-time animated visualization of the Rapidly-Exploring Random Tree (RRT) algorithm — a sampling-based motion planner widely used in robotics. The tree grows from an initial configuration by randomly sampling the workspace and extending toward sampled points, efficiently exploring the configuration space while avoiding randomly generated circular obstacles.

How It Works

  1. 1Sample a random point q_random in the configuration space.
  2. 2Find the nearest existing node q_near in the tree using Euclidean distance.
  3. 3Extend from q_near toward q_random by step size delta to compute q_new.
  4. 4If q_new is collision-free (passes point-in-circle checks), add it to the tree and draw the edge.
  5. 5Repeat for K iterations, building out the exploration tree in real time.

Parameters

  • q_init = [50, 50] — starting configuration
  • delta = 2 — step size per iteration
  • K = 500 — number of iterations
  • max_circles = 15 — number of random obstacles
  • D = [0,100] x [0,100] — workspace bounds

Key Concepts

  • Configuration Space Sampling: Uniform random sampling over a bounded 2D workspace.
  • Nearest Neighbor Search: Euclidean distance to find the closest tree node.
  • Collision Detection: Point-in-circle checks against a randomly generated obstacle list.
  • Real-Time Visualization: Matplotlib FuncAnimation for live frame-by-frame tree rendering.

Quickstart

pip install numpy matplotlib
python randomly_exploring_random_tree.py