What is around me?
Perception turns camera frames and range echoes into obstacle positions in the robot's own frame.
Open source · Python · Robotics
A complete autonomy stack for a mobile robot: it sees obstacles with computer vision, maps them from its sensors, plans a collision-free route with A*, and drives it with pure pursuit, guarded by a safety layer.
|
A robot must reach a goal in an environment it only partly knows, and never hit anything. Every decision depends on answering two questions continuously.
Perception turns camera frames and range echoes into obstacle positions in the robot's own frame.
A global planner routes around everything known, and replans when the sensors reveal something new.
Control tracks the path, slows down near obstacles, and a safety layer can override the planner.
Every control cycle (every 50 ms of simulated time) runs through these stages. Watch the signal travel.
This is replayed from the recorded data of an actual simulation (seed 7). Amber obstacles are unknown to the robot until its sensors see them. Watch the rays, the detection pulses, and the replan flashes.
Every layer is written in plain Python so you can read and change it.
HSV colour masking, morphological clean-up, contour fitting, pixel→metre conversion in the robot frame.
obstacle_detector.pyRay-casts across the image to find the most open direction. Used as a reactive fallback.
free_space.pyCamera detections and ultrasonic echoes write into one occupancy grid, skipping arena-wall echoes.
navigator.py8-connected A* with no corner cutting, octile heuristic, line-of-sight smoothing and 0.1 m resampling.
astar.pyGeometric path tracker with a 1 m lookahead, turn-based slowdown and side repulsion.
pure_pursuit.pyFront-sensor braking overrides the planner. Side sensors slow and push the robot away.
navigator.pyIf no path exists at full clearance, it retries at a smaller one. If that fails, it stops instead of driving blind.
navigator.pyThe same navigator drives a Raspberry Pi robot through HC-SR04, L298N and camera drivers.
run_robot.pyReal bugs found by tracing the run, and the fixes that were measured on 60 seeds.
Pure pursuit steered at sparse waypoints, so the lookahead point could sit across an obstacle. Fix: resample the path to 0.1 m spacing.
Walls were not inflated in the planning grid. Fix: block cells within the safety margin of every wall.
Periodic replanning chose the other side of an obstacle each time. Fix: replan on real events and off-path drift only.
The emergency stop watched side sensors and deadlocked. Fix: brake on the front, slow down on the sides.
A narrow gap plus a 0.5 m margin left no route. Fix: graceful degradation, then a safe stop.
The tracker searched only 40 points ahead. Fix: search the full path and replan on 0.5 m cross-track error.
Each bar is one simulated episode from the open-source benchmark_results.csv. Green reached the goal, red did not.
Step-by-step Jupyter notebooks for computer vision, path planning, and statistical benchmark analysis, plus pre-built custom environment maps.
Explore dual-band HSV red segmentation, morphological filtering, metric contour fitting, and angular free-space ray-casts.
Compare grid inflation safety margins, 8-connected A* search, line-of-sight shortcutting, and 0.1 m path resampling.
Quantitative evaluation over 60 seeded runs: KPI distributions, clearance safety margins, and path efficiency metrics.
Screenshots generated from the real simulation. Click any image to enlarge it.







Requires Python 3.11+. No GPU needed.
git clone https://github.com/rohitsingh83/AI-Autonomous-Navigation-System.git
cd AI-Autonomous-Navigation-System
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
python main.py run --seed 7 --gif
python main.py benchmark --episodes 60
pytest -q
Windows: use .venv\Scripts\activate. Outputs go to outputs/.
The Raspberry Pi pin map (BCM). It fixes a GPIO 23 clash in the original guide.
| Part | Signal | GPIO |
|---|---|---|
| HC-SR04 | TRIG / ECHO* | 23 / 24 |
| L298N left | IN1 / IN2 / ENA | 17 / 18 / 12 |
| L298N right | IN3 / IN4 / ENB | 27 / 22 / 13 |
*ECHO outputs 5 V. Use a 1 kΩ / 2 kΩ divider to protect the Pi's 3.3 V pin.
Found a bug or have a better planner? Open an issue or a pull request. The benchmark is the regression check.