A fully visualized implementation of the Dynamic Window Approach (DWA) in Python using Pygame. Simulate and visualize obstacle avoidance and goal-reaching for mobile robots in 2D space — perfect for robotics beginners, path planning researchers, and AI robotics students!
Dynamic Window Approach is a real-time collision avoidance algorithm for mobile robots. It evaluates a set of feasible trajectories based on the robot's dynamic constraints, obstacle proximity, and goal direction.
This project:
- Predicts multiple future trajectories
- Scores each based on distance to goal, speed, and safety
- Selects the best trajectory and visualizes it
- Runs smoothly in a Pygame window with live user interaction!
- 📍 Real-time path planning to a user-defined goal
⚠️ Dynamic obstacle addition with right-click- 🧭 Visualized prediction trajectories
- 🚗 Simulated robot with circular collision model
- 🧪 Easy to tweak robot config for experiments
- Left-click to set a new goal
- Right-click to add a new obstacle
- Window will auto-close once robot reaches goal
- Python 3.7+
- Pygame
- NumPy
pip install pygame numpy
python DWA.py
Easily adjust robot dynamics and cost weights in the Config class:
self.max_speed = 1.0
self.max_accel = 0.2
self.to_goal_cost_gain = 0.1
self.obstacle_cost_gain = 0.5
...
- ✅ Learn path planning through visualization
- ✅ Great teaching material for robotics classes
- ✅ Easy to hack and extend (e.g., LIDAR input, map loading)
- ✅ No ROS or external frameworks required
If you found this useful or interesting, give it a ⭐ to support more open robotics projects!