Implementation of the Rapidly-exploring Random Tree (RRT) algorithm for motion planning in C++ using OpenRAVE.
This repository contains a C++ implementation of the Rapidly-exploring Random Tree (RRT) algorithm, a popular sampling-based motion planning algorithm. The implementation uses OpenRAVE (Open Robotics Automation Virtual Environment) for robot simulation and visualization.
This was completed as part of a Motion Planning course at Worcester Polytechnic Institute (WPI).
A Rapidly-exploring Random Tree (RRT) is a data structure and algorithm designed for efficiently searching non-convex high-dimensional spaces. Key properties:
- π³ Incremental construction: Tree grows by adding random samples
- π― Biased exploration: Tends to grow toward unexplored regions
- π High-dimensional spaces: Effective for robots with many DOF
- π§ Obstacle handling: Naturally handles obstacles and constraints
RRT can be viewed as:
- A Monte Carlo method for exploring configuration space
- Biasing search into largest Voronoi regions
- A technique for generating open-loop trajectories
- π RRT Algorithm: Core tree expansion and connection
- πΊοΈ Path Planning: Find collision-free paths
- π Visualization: 3D visualization via OpenRAVE
- π€ Robot Support: Works with various robot models
- π§ Obstacle Avoidance: Handles static obstacles
- Language: C++
- Simulation: OpenRAVE
- Visualization: OpenRAVE viewer
- Build: Make/CMake
- C++ compiler (GCC 4.8+ or Clang 3.4+)
- OpenRAVE 0.9+
- Boost libraries
# Install dependencies
sudo apt-get install cmake g++ libboost-all-dev
# Install OpenRAVE
sudo apt-get install openrave
# Or build from source (see OpenRAVE documentation)# Clone the repository
git clone https://github.com/leelening/RRT.git
cd RRT
# Build
make
# or
mkdir build && cd build
cmake ..
make# Run RRT planner with default scene
./rrt_planner
# Run with custom scene
./rrt_planner scene.env.xml
# Run with specific start and goal
./rrt_planner --start "0 0 0" --goal "5 5 0"./rrt_planner [options]
--scene FILE # Load scene file
--robot NAME # Specify robot name
--start "x y z" # Start configuration
--goal "x y z" # Goal configuration
--max-nodes N # Maximum tree nodes (default: 10000)
--step-size S # Step size for extension
--visualize # Enable visualization.
βββ src/ # Source code
β βββ rrt.cpp # RRT algorithm implementation
β βββ rrt.h # RRT header file
β βββ main.cpp # Main entry point
β βββ utils.cpp # Utility functions
βββ scenes/ # OpenRAVE scene files
β βββ *.env.xml
βββ robots/ # Robot model files
β βββ *.robot.xml
βββ include/ # Header files
βββ Makefile # Build configuration
βββ README.md # This file
Algorithm RRT(q_init, K, Ξt):
T.init(q_init)
for k = 1 to K do
q_rand β RANDOM_CONFIG()
q_near β NEAREST_VERTEX(q_rand, T)
q_new β NEW_CONFIG(q_near, q_rand, Ξt)
if COLLISION_FREE(q_near, q_new) then
T.add_vertex(q_new)
T.add_edge(q_near, q_new)
end if
end for
return T
- Random Sampling: Uniform sampling in configuration space
- Nearest Neighbor: Find closest node in tree
- Steering: Extend toward sample with step size
- Collision Checking: Verify edge is collision-free
The repository may include or be extended with:
- RRT-Connect: Bidirectional RRT for faster convergence
- RRT*: Asymptotically optimal RRT
- Kinodynamic RRT: Handles differential constraints
- RRT with obstacles: Enhanced collision detection
OpenRAVE provides:
- Robot kinematics and dynamics
- Collision checking
- 3D visualization
- Scene loading and management
- Course: Motion Planning
- Institution: Worcester Polytechnic Institute (WPI)
- Year: 2015
- Focus: Sampling-based motion planning algorithms
- Configuration space (C-space)
- Sampling-based planning
- Probabilistic completeness
- Motion planning under constraints
- Robot kinematics
Example paths found by the RRT planner:
Start: (0, 0, 0)
Goal: (5, 5, Ο/4)
Path length: 12.3 units
Nodes expanded: 847
Planning time: 2.3 seconds
Possible improvements:
- RRT* for optimal paths
- RRT-Connect for faster planning
- Anytime RRT for real-time applications
- Sampling strategies (Gaussian, bridge)
Academic use only.
Lening Li
- GitHub: @leelening