A 2D autonomous rover navigation simulator in Python. The rover builds an occupancy map incrementally from LIDAR scans and plans paths using Optimistic A*, with frontier-based exploration as fallback.
- Randomized occupancy grid with configurable obstacle density
- Simulated LIDAR sensor with configurable range (Manhattan footprint)
- Optimistic A*: unknown cells assumed free, replans on obstacle discovery
- Frontier-based exploration fallback when goal is not yet reachable
- Reachability check before navigation — handles unreachable goals gracefully
- Step-by-step animated visualization with dual obstacle layer and mode coloring
- Python 3.10+
- numpy
- matplotlib
pip install numpy matplotlibpython main.py| Flag | Default | Description |
|---|---|---|
--width |
20 | Grid width |
--height |
20 | Grid height |
--obstacles |
0.25 | Obstacle density (0.0–1.0) |
--seed |
None | Random seed for reproducibility |
--sensor-radius |
4 | LIDAR range in cells |
--interval |
120 | Animation frame interval (ms) |
# Default 20×20 grid
python main.py
# Larger grid, denser obstacles
python main.py --width 30 --height 30 --obstacles 0.3
# Reproducible run
python main.py --seed 42
# Smaller sensor range, slower animation
python main.py --sensor-radius 2 --interval 200The rover uses Optimistic A*: unknown cells are treated as free when planning, so the rover heads directly toward the goal and only replans when an obstacle is discovered on the current path. If the goal is unreachable on the known map, it falls back to frontier exploration — navigating to the nearest boundary between known and unknown space to expand its map.
The path cost function is f(n) = g(n) + h(n), where g(n) is the number of
steps from start and h(n) is the Manhattan distance to the goal.
| Color | Meaning |
|---|---|
| 🔴 Red | Rover |
| 🟢 Green | Trail — heading to goal |
| 🟠 Orange | Trail — frontier exploration |
| 🔵 Light blue | Sensor FOV |
| 🟣 Purple | Frontier cells |
| ⬛ Dark | Detected obstacle |
| ⬜ Medium gray | Hidden obstacle (hint) |
| Light gray | Unknown cell |
This project is licensed under the MIT License. See the LICENSE file for full details.