A Β· RRT Β· Dynamic Replanning Β· PID Waypoint Control**
Built from scratch in Python β no robotics libraries used for core algorithms.
This project implements a complete 3D drone navigation pipeline:
- 3D Occupancy Grid β discrete voxel environment with random/custom obstacles
- Path Planning β A* (optimal grid search) and RRT* (probabilistic sampling), implemented from scratch
- Dynamic Replanning β mid-flight obstacle injection triggers real-time replan
- PID Flight Simulation β simulated drone tracks planned waypoints using PID control
Goal: Demonstrate understanding of robotics fundamentals for an MSc Robotics application.
drone_path_planning/
β
βββ main.py # Entry point β runs all phases
β
βββ src/
β βββ environment.py # 3D Occupancy Grid (Phase 1)
β βββ visualizer.py # 3D rendering + animation (Phase 1)
β βββ astar.py # A* algorithm from scratch (Phase 2)
β βββ rrt_star.py # RRT* algorithm from scratch (Phase 2)
β βββ replanner.py # Dynamic obstacle + replanning (Phase 3)
β βββ pid_controller.py # PID controller + drone physics (Phase 4)
β
βββ results/ # Generated plots, GIFs, saved grids
βββ maps/ # Custom map configs (.npy)
βββ tests/ # Unit tests
β
βββ requirements.txt
βββ README.md
# Clone the repo
git clone https://github.com/MedisettiRenukeswar/3d-drone-path-planning.git
cd drone-path-planning
# Install dependencies
pip install -r requirements.txt
# Run full pipeline (all 4 phases)
python main.py
# Run with specific options
python main.py --algo astar # A* only
python main.py --algo rrt # RRT* only
python main.py --algo compare # Side-by-side comparison
python main.py --seed 7 # Different random environment
python main.py --no-anim --no-show # Headless mode (save plots only)The environment is a discrete 3D voxel grid of shape (X, Y, Z).
grid[x][y][z] = 0β free spacegrid[x][y][z] = 1β obstacle
Supports box obstacles, cylinder obstacles, and random generation with fixed seeds for reproducibility.
A* finds the optimal (shortest) path by maintaining a priority queue ordered by:
f(n) = g(n) + h(n)
Where:
g(n)= actual cost from start to nodenh(n)= heuristic estimate to goal (Euclidean distance)f(n)= estimated total cost throughn
Heuristic used: Euclidean distance in 3D:
h(n) = sqrt((xβ-xβ)Β² + (yβ-yβ)Β² + (zβ-zβ)Β²)
Why Euclidean? It is admissible (never overestimates) and consistent in 3D continuous space, guaranteeing the optimal path.
26-connectivity: Each voxel has up to 26 neighbors (face + edge + corner), with diagonal step costs computed as sqrt(dxΒ²+dyΒ²+dzΒ²).
RRT* is a probabilistic sampling algorithm that builds a tree by randomly exploring the space:
- Sample a random point
q_randin the 3D grid - Find nearest tree node
q_near - Steer from
q_neartowardq_randbystep_size - Collision check the new segment
- Choose best parent β among nearby nodes, pick the one giving lowest cost to
q_new - Add node to tree
- Rewire β check if any neighbor benefits from re-routing through
q_new
The rewiring step is what makes RRT* asymptotically optimal (unlike basic RRT).
Key difference from A*:
| Property | A* | RRT* |
|---|---|---|
| Optimality | Globally optimal | Asymptotically optimal |
| Environment | Grid-based | Continuous C-space |
| Speed | Fast (small grids) | Slower (sampling) |
| Path quality | Optimal | Improves with iterations |
| Memory | High (explored nodes) | Lower |
Simulates a mid-flight obstacle appearance:
- Drone begins flying the initial planned path
- At 40% of the path, a new obstacle is injected
- System detects path is blocked (
path_is_clear()check) - Replanning triggered from current drone position to goal
- Drone continues on new path
This mimics real-world scenarios: another drone enters the airspace, a human crosses the path, a door closes.
The drone follows planned waypoints using a 3-axis PID controller:
u(t) = KpΒ·e(t) + KiΒ·β«e(t)dt + KdΒ·de/dt
Each axis (X, Y, Z) has an independent PID. The drone physics use a simplified point-mass model:
v(t+dt) = v(t) + a(t)Β·dt - dampingΒ·v(t)Β·dt
p(t+dt) = p(t) + v(t)Β·dt
Anti-windup and output clamping prevent actuator saturation.
| Metric | A* | RRT* |
|---|---|---|
| Path Length | ~32.4 m | ~35.1 m |
| Nodes Explored | ~1,840 | ~2,100 |
| Planning Time | ~12 ms | ~180 ms |
| Replan Time | ~9 ms | ~210 ms |
Results vary by environment seed. Run
python main.py --algo compareto generate your own metrics.
This shows the generated 3D voxel occupancy grid with randomly placed obstacles.
A* computes the optimal path from start to goal using a Euclidean heuristic and 26-connected neighbor expansion.
RRT* explores the configuration space using probabilistic sampling and improves the path using rewiring.
Side-by-side comparison between deterministic A* and sampling-based RRT*.
Comparison of path length, nodes explored, and planning time.
When a new obstacle appears mid-flight, the planner detects blockage and recomputes a safe path.
Drone trajectory following A* waypoints using PID control.
Drone trajectory following RRT* path with PID waypoint tracking.
Why implement from scratch?
Using libraries like python-robotics hides the actual algorithm. Implementing A* and RRT* manually forces understanding of the data structures (min-heap, tree), the math (heuristic admissibility, cost propagation), and the edge cases (out-of-bounds, start/goal in obstacle).
Why 26-connectivity over 6? In 3D space, restricting to only face-adjacent neighbors forces the drone to take "staircase" paths instead of diagonal shortcuts. 26-connectivity produces more natural, shorter paths at the cost of a larger branching factor.
Why Euclidean heuristic over Manhattan? Manhattan distance is inadmissible in 26-connected 3D grids (it underestimates less, but counts only axis-aligned moves). Euclidean distance is strictly admissible and consistent, guaranteeing A* finds the optimal path.
| Library | Version | Usage |
|---|---|---|
numpy |
β₯1.24 | Grid, vector math, path operations |
matplotlib |
β₯3.7 | 3D visualization, animation |
No ROS, no AirSim, no robotics libraries. Pure Python.
- SLAM integration (build map while navigating)
- RL-based planner (replace A* with trained policy)
- Multi-drone coordination (shared occupancy grid)
- Real hardware deployment (ArduPilot / DJI Tello)
- Streamlit web UI for mission control demo
Medisetti Renukeswar
B.Tech Computer Science & Engineering
Applying for MSc Robotics β TU Munich / KIT / TU Berlin
MIT License β free to use, modify, and distribute.







