A Python-based visual simulator for an autonomous Roomba robot that cleans 3 rooms with obstacle avoidance, battery management, and intelligent pathfinding.
This project demonstrates a 4-layer software architecture for a mobile robot:
- Entry Point (
main.py) — initialization and main loop - Decision Brain (
controller.py) — state machine and control logic - Logic Helpers (
scheduler.py,home_mapper.py) — scheduling and spatial mapping - Hardware Layer (
hardware_simulator.py) — motor and sensor simulation
The robot automatically cleans 3 rooms at a scheduled time, with real-time visualization showing:
- Room layout and obstacle placement
- Robot position and movement
- Battery level and charging cycles
- Dust bin status
- Cleaned floor percentage (accounting for unreachable areas)
- Visual Simulator — tkinter GUI showing live cleaning animation
- Obstacle System — click to place/remove walls; robot skips unreachable areas
- Intelligent Navigation — A* pathfinding to navigate around obstacles
- Battery Management — robot returns to dock at 50% battery for charging
- Reachability Analysis — BFS flood-fill to identify physically accessible cells
- Grid-Based Cleaning — systematic 10x10 grid pattern through each room
- Python 3.x
- tkinter — GUI visualization
- heapq — A* pathfinding algorithm
- Collections — BFS queue for reachability analysis
- Clone the repository:
git clone https://github.com/kaskus90/robot_project.git
cd robot_project- No external dependencies — uses only Python standard library.
python -X utf8 src/visualizer.pyThe -X utf8 flag ensures emoji display works correctly on Windows.
- Watch the simulation — robot automatically starts cleaning at 14:00 (2 PM)
- Place obstacles — click on any room cell to add a red wall (click again to remove)
- Monitor status — right panel shows battery %, dust bin %, cleaned %, and robot state
- Battery charging — when battery reaches 50%, robot returns to yellow dock station to recharge
src/
├── main.py # Basic CLI version (non-visual)
├── visualizer.py # Interactive GUI simulator
├── controller.py # Robot control logic & state machine
├── hardware_simulator.py # Motor and sensor simulation
├── scheduler.py # Cleaning schedule management
├── home_mapper.py # Room layout and grid generation
└── pathfinder.py # A* pathfinding algorithm
Controller State Machine:
IDLE→CLEANING→MOVING_TO_ROOM→AVOIDING/DOCKED
Hardware Components:
- Motors: LEFT, RIGHT (movement), BRUSH, VACUUM (cleaning)
- Sensors: Sonar (distance), Dust level
Robot Behavior:
- Checks schedule → starts cleaning at 14:00
- Navigates to each room in sequence
- Cleans in 10x10 grid pattern
- Skips obstacle cells using A* pathfinding
- Returns to dock when battery < 50% or dust bin > 90%
- Charges and empties bin before resuming
A Pathfinding* — finds shortest path around obstacle clusters to reach next cleanable cell
BFS Reachability — identifies all grid cells physically accessible from the robot's starting position (prevents cleaning inside walled areas)
- Green cells — successfully cleaned
- White cells — unreachable (inside walls)
- Red cells — obstacles
- Orange circle — robot position
- Yellow square — charging dock
This project demonstrates:
- Layered software architecture
- State machine design
- Pathfinding algorithms
- Sensor simulation
- Hardware abstraction
- Real-time visualization
Kuba K. (kaskus90)
Open source for educational purposes.