# rukmanishahi/smart-warehouse-autonomous-robot architecture

> Architecture diagram of the GitHub repository rukmanishahi/smart-warehouse-autonomous-robot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rukmanishahi/smart-warehouse-autonomous-robot
- Repository: https://github.com/rukmanishahi/smart-warehouse-autonomous-robot

## Overview

#### Purpose and entry points
Tempest AMR is a reference control stack for warehouse box sorting: camera-derived attributes are classified, mapped to a destination, issued to an ESP32 robot controller, and confirmed after drop. Primary host entry point is `sorting_controller.py`; embedded entry point is `esp32_firmware.ino`. `motor_control.ino` is a related Arduino motor-control unit.

#### Host orchestration state machine
`sorting_controller.py` owns the sorting cycle and state transitions: IDLE → SCAN → CLASSIFY → MOVE → DROP → IDLE. It coordinates camera classification, routing decisions, serial commands, and returned robot status. This is the primary control-plane boundary between high-level sorting policy and physical actuation.
- `sorting_controller.py`
- `serial_bridge.py`

#### Vision and item attribute extraction
`vision_classifier.py` uses OpenCV-oriented logic to derive sortable box attributes, including color, size, and potentially barcode information. Its calibration-sensitive thresholds isolate camera/lighting concerns from downstream routing logic.
- `vision_classifier.py`
- `requirements.txt`

#### Routing and sorting policy
`decision_engine.py` converts classified item attributes into a destination bin or movement target. The current design is rule/lookup based, while the README identifies a future boundary to map-aware navigation such as ROS 2 Nav2/A*; that planner is not present in this repository.
- `decision_engine.py`
- `sorting_controller.py`

#### Serial protocol boundary
`serial_bridge.py` is the host-side UART adapter to the ESP32. Commands flow Python → serial → firmware; status/confirmation flows firmware → serial → Python. This boundary decouples Python runtime logic from Arduino/C++ hardware implementation and requires a configured serial port at launch.
- `serial_bridge.py`
- `sorting_controller.py`
- `esp32_firmware.ino`

#### Embedded robot control and sensing
The ESP32 firmware implements low-level motor/encoder movement, arm/servo actuation, sensor handling, bin movement table behavior, drop confirmation, and serial command processing. Hardware-dependent values—including pin mapping, encoder distance/turn calibration, load-cell scale, attachment-ID voltage bands, and bin coordinates—belong on this side.
- `esp32_firmware.ino`
- `motor_control.ino`

#### Local device UI and infrastructure
In addition to serial control, the ESP32 creates its own Wi-Fi access point and hosts a simple browser control page through Arduino WiFi/WebServer facilities. It uses ESP32 Arduino libraries plus HX711 and ESP32Servo for hardware integration. The host runtime is Python with dependencies declared in `requirements.txt`; no cloud service or server infrastructure is indicated.
- `esp32_firmware.ino`
- `requirements.txt`

Main entry points: [`esp32_firmware.ino`](https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/esp32_firmware.ino) (ESP32 firmware), [`sorting_controller.py`](https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/sorting_controller.py) (Sorting controller), [`serial_bridge.py`](https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/serial_bridge.py) (Serial bridge), [`vision_classifier.py`](https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/vision_classifier.py) (Vision classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_host["Host control"]
  node_controller["Sorting controller<br/>Python state machine"]
  node_vision["Vision classifier<br/>OpenCV classification"]
  node_routing["Decision engine<br/>Rule routing<br/>[decision_engine.py]"]
  node_serial["Serial bridge<br/>UART adapter<br/>[serial_bridge.py]"]
  node_python_deps["Host dependencies<br/>Python requirements<br/>[requirements.txt]"]
end

subgraph group_embedded["ESP32 robot"]
  node_firmware["ESP32 firmware<br/>Arduino firmware<br/>[esp32_firmware.ino]"]
  node_command_protocol["Command processing<br/>Serial protocol<br/>[esp32_firmware.ino]"]
  node_motion["Motion control<br/>Motor and encoder control<br/>[esp32_firmware.ino]"]
  node_drop["Drop mechanism<br/>Arm and servo control<br/>[esp32_firmware.ino]"]
  node_sensing["Robot sensors<br/>[esp32_firmware.ino]"]
  node_motor_unit["Motor control unit<br/>Arduino motor control<br/>[motor_control.ino]"]
  node_device_ui["Local web control<br/>[esp32_firmware.ino]"]
end

node_camera(("Camera input<br/>Physical camera"))
node_robot_hardware{{"Robot hardware<br/>Motors, encoders, servo, sensors"}}
node_browser(("Browser<br/>Local device client"))

node_camera -->|"frames"| node_vision
node_controller -->|"scan / classify"| node_vision
node_vision -->|"item attributes"| node_routing
node_routing -->|"destination target"| node_controller
node_controller -->|"robot command"| node_serial
node_serial -->|"UART commands"| node_firmware
node_firmware -->|"status / confirmation"| node_serial
node_serial -->|"robot status"| node_controller
node_firmware -->|"dispatches"| node_command_protocol
node_command_protocol -->|"move commands"| node_motion
node_command_protocol -->|"drop commands"| node_drop
node_sensing -->|"sensor readings"| node_firmware
node_motion -->|"motor control"| node_robot_hardware
node_drop -->|"servo actuation"| node_robot_hardware
node_robot_hardware -->|"encoder and sensor signals"| node_sensing
node_firmware -->|"hosts"| node_device_ui
node_browser -->|"local Wi-Fi access"| node_device_ui
node_motor_unit -.->|"motor control"| node_robot_hardware
node_python_deps -.->|"runtime packages"| node_vision

click node_controller "https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/sorting_controller.py"
click node_vision "https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/vision_classifier.py"
click node_routing "https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/decision_engine.py"
click node_serial "https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/serial_bridge.py"
click node_python_deps "https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/requirements.txt"
click node_firmware "https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/esp32_firmware.ino"
click node_command_protocol "https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/esp32_firmware.ino"
click node_motion "https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/esp32_firmware.ino"
click node_drop "https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/esp32_firmware.ino"
click node_sensing "https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/esp32_firmware.ino"
click node_motor_unit "https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/motor_control.ino"
click node_device_ui "https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/esp32_firmware.ino"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_controller,node_vision,node_routing,node_serial,node_python_deps toneBlue
class node_firmware,node_command_protocol,node_motion,node_drop,node_sensing,node_motor_unit,node_device_ui toneAmber
class node_camera,node_robot_hardware,node_browser toneNeutral
```

## Components

### Host control

Python sorting control plane.

- [Sorting controller](https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/sorting_controller.py): Python state machine · Runs IDLE → SCAN → CLASSIFY → MOVE → DROP. · `sorting_controller.py`
- [Vision classifier](https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/vision_classifier.py): OpenCV classification · Extracts color, size, and possible barcode attributes. · `vision_classifier.py`
- [Decision engine](https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/decision_engine.py): Rule routing · Maps item attributes to destination bins or targets. · `decision_engine.py`
- [Serial bridge](https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/serial_bridge.py): UART adapter · Translates host commands and returned robot status. · `serial_bridge.py`
- [Host dependencies](https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/requirements.txt): Python requirements · `requirements.txt`

### ESP32 robot

Firmware, hardware control, and local device UI.

- [ESP32 firmware](https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/esp32_firmware.ino): Arduino firmware · Processes serial commands and coordinates robot operation. · `esp32_firmware.ino`
- [Command processing](https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/esp32_firmware.ino): Serial protocol · Receives movement and drop commands; returns status. · `esp32_firmware.ino`
- [Motion control](https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/esp32_firmware.ino): Motor and encoder control · Executes calibrated bin movement and turns. · `esp32_firmware.ino`
- [Drop mechanism](https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/esp32_firmware.ino): Arm and servo control · Actuates drops and confirms completion. · `esp32_firmware.ino`
- [Robot sensors](https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/esp32_firmware.ino): Load cell and attachment sensing · Supplies hardware confirmation and identification signals. · `esp32_firmware.ino`
- [Motor control unit](https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/motor_control.ino): Arduino motor control · Related standalone motor-control implementation. · `motor_control.ino`
- [Local web control](https://github.com/rukmanishahi/smart-warehouse-autonomous-robot/blob/main/esp32_firmware.ino): Wi-Fi AP and web server · Serves a browser control page from the ESP32. · `esp32_firmware.ino`

### Other components

- **Camera input**: Physical camera
- **Robot hardware**: Motors, encoders, servo, sensors
- **Browser**: Local device client

## Connections

- Camera input → Vision classifier: frames
- Sorting controller → Vision classifier: scan / classify
- Vision classifier → Decision engine: item attributes
- Decision engine → Sorting controller: destination target
- Sorting controller → Serial bridge: robot command
- Serial bridge → ESP32 firmware: UART commands
- ESP32 firmware → Serial bridge: status / confirmation
- Serial bridge → Sorting controller: robot status
- ESP32 firmware → Command processing: dispatches
- Command processing → Motion control: move commands
- Command processing → Drop mechanism: drop commands
- Robot sensors → ESP32 firmware: sensor readings
- Motion control → Robot hardware: motor control
- Drop mechanism → Robot hardware: servo actuation
- Robot hardware → Robot sensors: encoder and sensor signals
- ESP32 firmware → Local web control: hosts
- Browser → Local web control: local Wi-Fi access
- Motor control unit → Robot hardware: motor control
- Host dependencies → Vision classifier: runtime packages
