# ai-robot-book-humble/chapter1 architecture

> Architecture diagram of the GitHub repository ai-robot-book-humble/chapter1, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ai-robot-book-humble/chapter1
- Repository: https://github.com/ai-robot-book-humble/chapter1

## Overview

##### Project type and purpose
- This repository is an educational, sample‑code project for “Chapter 1: AIロボットをつくろう！（改訂第2版）,” demonstrating how to build and run simple ROS 2 + Python robot programs. It provides multiple setup flavors (Docker, native/non‑Docker, colcon symlink install) and includes support for the Happy Mini Open Platform hardware.

##### File structure
- Top‑level directories:
- colcon – instructions to launch builds with `colcon build --symlink-install`
- docker – Dockerfiles and instructions to stand up a complete ROS 2 development & simulation environment (linux real hardware or Windows‐only sim)
- happy_mini_open_platform – ROS 2 packages & launch files tailored to the Happy Mini robot (Humble)
- non_docker – native install instructions for ROS 2 Humble without Docker
- docker/images – container image definitions (base OS, ROS 2 dependencies, sample code)
- README files in each folder specify setup steps, dependencies, and launch commands.

##### README for additional insights
- The main README outlines purpose and directory roles.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layer 1: Development
    subgraph "Development Layer"
        direction TB
        Developer["Developer Workstation (IDE/CLI)"]:::boundary
    end
    click Developer "https://github.com/ai-robot-book-humble/chapter1/blob/main/README.md"

    %% Layer 2: Environment Setup
    subgraph "Environment Setup" 
        direction TB
        subgraph "Docker Environment" 
            direction TB
            DockerEnv["Docker Container"]:::boundary
            DockerImages["Image Definitions"]:::build
            DockerReadme["Docker Setup Instructions"]:::build
        end
        subgraph "Native Environment" 
            direction TB
            NativeEnv["Native ROS 2 Humble Install"]:::boundary
            NativeReadme["Native Install Instructions"]:::build
        end
    end
    click DockerEnv "https://github.com/ai-robot-book-humble/chapter1/tree/main/docker/"
    click DockerImages "https://github.com/ai-robot-book-humble/chapter1/tree/main/docker/images/"
    click DockerReadme "https://github.com/ai-robot-book-humble/chapter1/blob/main/docker/README.md"
    click NativeEnv "https://github.com/ai-robot-book-humble/chapter1/tree/main/non_docker/"
    click NativeReadme "https://github.com/ai-robot-book-humble/chapter1/blob/main/non_docker/README.md"

    Developer -->|"select environment"| DockerEnv
    Developer -->|"select environment"| NativeEnv

    %% Layer 3: Build
    subgraph "Build Layer"
        direction TB
        Colcon["colcon Build Tool (--symlink-install)"]:::build
        ColconReadme["Colcon Build Instructions"]:::build
        Colcon -->|"build workspace"| Workspace["install/ & build/"]:::build
    end
    click Colcon "https://github.com/ai-robot-book-humble/chapter1/tree/main/colcon/"
    click ColconReadme "https://github.com/ai-robot-book-humble/chapter1/blob/main/colcon/README.md"

    DockerEnv -->|"runs build"| Colcon
    NativeEnv -->|"runs build"| Colcon

    %% Layer 4: Runtime Initialization
    subgraph "Runtime Initialization"
        direction TB
        Ros2Daemon["ros2 daemon"]:::runtime
        Ros2Daemon -->|"load packages"| RuntimeWorkspace["Workspace Overlay"]:::runtime
    end
    Workspace --> Ros2Daemon

    %% Layer 5: Application & Middleware
    subgraph "ROS 2 Runtime" 
        direction TB
        Middleware["ROS 2 Middleware (rclpy, DDS/RTPS)"]:::runtime
        Core["ROS 2 Core (topic/service/action graph)"]:::runtime
        Apps["Robot Application Packages (Python nodes)"]:::runtime
        AppReadme["Package Instructions & Launch Files"]:::runtime
        click Apps "https://github.com/ai-robot-book-humble/chapter1/tree/main/happy_mini_open_platform/"
        click AppReadme "https://github.com/ai-robot-book-humble/chapter1/blob/main/happy_mini_open_platform/README.md"
    end
    RuntimeWorkspace --> Apps
    Apps -->|"publish Topic:/cmd_vel"| Core
    Apps -->|"service call /set_parameters"| Core
    Core -->|"deliver messages"| Apps
    Core -->|"use DDS network"| Middleware

    %% Layer 6: Communication Layer
    subgraph "Communication (DDS)" 
        direction TB
        DDS["DDS/RTPS Network"]:::runtime
    end
    Middleware --> DDS
    DDS --> Middleware

    %% Layer 7: Execution
    subgraph "Execution Layer"
        direction TB
        Simulator["Simulator (Gazebo plugin)"]:::hardware
        Hardware["Real Robot Hardware & Sensors"]:::hardware
    end
    DDS -->|"publish/subscribe"| Simulator
    DDS -->|"publish/subscribe"| Hardware

    %% Legend
    subgraph "Legend"
        direction TB
        Build["Build-time"]:::build
        Runtime["Runtime"]:::runtime
        HardwareLeg["Hardware/Simulation"]:::hardware
        Boundary["Environment Boundary"]:::boundary
    end

    classDef build fill:#ADD8E6,stroke:#333;
    classDef runtime fill:#90EE90,stroke:#333;
    classDef hardware fill:#FFA500,stroke:#333;
    classDef boundary fill:#D3D3D3,stroke:#888,stroke-dasharray: 5 5;
    class Developer,DockerEnv,NativeEnv,Workspace boundary;
    class Colcon,ColconReadme,DockerImages,DockerReadme,NativeReadme,Build build;
    class Ros2Daemon,RuntimeWorkspace,Middleware,Core,Apps,DDS runtime;
    class Simulator,Hardware hardware;
    class Build,Runtime,HardwareLeg,Boundary boundary;
```
