# anhbantre/personfollowingrobot architecture

> Architecture diagram of the GitHub repository anhbantre/personfollowingrobot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anhbantre/personfollowingrobot
- Repository: https://github.com/anhbantre/personfollowingrobot

## Overview

##### Project Type & Purpose
- The project is a robotics application with a strong focus on computer vision and AI. Its purpose is to create a smart trolley— a person-following robot— that can handle complex indoor environments by using 3D vision, deep learning-based object detection, and single object tracking.
- The README describes the use of a RealSense camera for depth sensing, ROS integration for middleware, and deep learning models (jetson-inference and Stark) converted to TensorRT for accelerated inference.

##### File Structure
- At the root, you have configuration files (.gitignore, LICENSE, and installation instructions for pyrealsense2), and two key Python files: human_detection.py and image_processing.py.
- The imgs directory holds various visual outputs and example images of floor detection and tracking, which suggests the importance of imaging in the pipeline.
- This indicates two primary software components: one dealing with human detection (likely interfacing with the deep learning model for tracking) and another focusing on image processing (preparing data for analysis, possibly including floor recognition).

##### Main Components
a. Hardware Components:
- Camera Sensor (Intel RealSense Depth D455): This is the primary sensor supplying both RGB and depth information.
- Board Computer (Jetson Nano): Processes the sensor data, runs the deep learning models, and handles ROS integration.
- Microcontroller (STM32F103C8T6): Likely used for low-level motor control and interfacing with the motor driver system.
- Motor Drivers & H-Bridge Driver: Interfaces that allow the control signals from either the Jetson Nano or microcontroller to drive the motors.
- Power System: Battery, voltage regulators, and associated circuitry.

b. Software Components:
- Sensor Driver Node: The ROS node or module that interfaces with the RealSense camera, capturing raw sensor data.
- Image Processing Node (image_processing.py): Processes the depth and image data to recognize floors and prepare data for detection.
- Human Detection/Tracking Node (human_detection.py): Uses deep learning models (using jetson-inference and Stark models, accelerated with TensorRT) to detect and track the person.
- ROS Communication Layer: The middleware that manages message passing between the various nodes, integrating sensor input with processing and control.
- Control/Actuation Node: Uses the output from detection & tracking to generate commands for the motors and drive the robot to follow the person.

##### Relationships and Interactions Between Components
- The RealSense camera sends raw data (both RGB and depth) to the Sensor Driver Node.
- This data is then passed to the Image Processing Node to perform floor recognition and potentially pre-filter the environment.
- Processed data is routed to the Human Detection/Tracking Node which employs deep learning techniques to locate and follow a person.
- All of these nodes communicate via ROS topics/services, ensuring real-time communication between the perception modules and the Control/Actuation Node.
- The Control node sends the appropriate drive commands (via ROS messages) to the microcontroller/motor drivers, which then actuate the robot’s motors.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hardware Components
    subgraph "Hardware Components"
        R["RealSense Camera (D455)"]:::hardware
        J["Board Computer (Jetson Nano)"]:::hardware
        M["Microcontroller (STM32F103C8T6)"]:::hardware
        D["Motor Drivers & H-Bridge"]:::hardware
        P["Power System (Battery, Voltage Regulators)"]:::hardware
    end

    %% Software Components (ROS Nodes)
    subgraph "Software Components (ROS Nodes)"
        S["Sensor Driver Node (RealSense)"]:::software
        I["Image Processing Node (image_processing.py)"]:::software
        H["Human Detection/Tracking Node (human_detection.py)<br>TensorRT accelerated"]:::software
        C["Control/Actuation Node"]:::software
        ROS["ROS Communication Layer"]:::middleware
    end

    %% Data Repository
    subgraph "Data Repository"
        V["Visual Output Repository (imgs)"]:::repository
    end

    %% Hardware connections
    R -->|"RGB & Depth Data"| S
    C -->|"Motor Commands"| M
    M -->|"Control Signal"| D

    %% Software data flows
    S -->|"Raw Sensor Data"| I
    S -->|"Raw Sensor Data"| H
    I -->|"Processed Data"| C
    H -->|"Detection Info"| C

    %% ROS Communication links
    S ---|"ROS Topics"| ROS
    I ---|"ROS Topics"| ROS
    H ---|"ROS Topics"| ROS
    C ---|"ROS Topics"| ROS

    %% Click events for components
    click H "https://github.com/anhbantre/personfollowingrobot/blob/main/human_detection.py"
    click I "https://github.com/anhbantre/personfollowingrobot/blob/main/image_processing.py"
    click V "https://github.com/anhbantre/personfollowingrobot/tree/main/imgs"
    click S "https://github.com/anhbantre/personfollowingrobot/blob/main/install_pyrealsense2.md"

    %% Styles
    classDef hardware fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef software fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef middleware fill:#FFEBCD,stroke:#000,stroke-width:2px;
    classDef repository fill:#FFE4E1,stroke:#000,stroke-width:2px;
```
