# apockill/pi_at_home architecture

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

- Interactive diagram: https://gitdiagram.com/apockill/pi_at_home
- Repository: https://github.com/apockill/pi_at_home

## Overview

##### Project Type and Purpose
- This is a full-stack robotics simulation and deployment project that combines several subsystems. The primary goals are:
- Providing a teleoperation interface for a physical/simulated robot (e.g., teleoperated MyArm).
- Generating synthetic datasets using Isaac Sim with domain randomization and trajectory replay.
- Integrating ROS2 nodes and custom robot protocols (found in the “pkgs” directory) for controlling the robot.
- Enabling data conversion (from Isaac Sim “synthetic” episodes to a dataset format acceptable to lerobot training pipelines).

##### Key Components
a. Container & Deployment Layer:
- CI/CD & Linting: Include the .github workflows and linting scripts (in .github/lint) that ensure code quality.

b. Simulation & Synthetic Data Generation:
- Isaac Sim & Extensions: Highlight the isaac_src folder that contains extensions, assets (scenes, materials, textures), and simulation environments. This component is responsible for rendering simulation scenes (e.g., “cube-to-cup-task”) and recording trajectories.
- Trajectory Recorder and Renderer: Show the roles of the trajectory synthesis extension (isaac_src/extensions/trajectory_synth) and the conversion scripts that transform recorded simulation episodes into dataset entries.

c. ROS2 Middleware & Robot Controllers:
- ROS2 Launch Profiles: Represent the “launch-profiles” (teleop_myarm and synthetic_generation) that start different robot operation modes (real teleoperation and synthetic data generation).
- ROS2 Integration & Robot Nodes: Include the pkgs directory (e.g., myarm_ai, myarm_ai_msgs) where the ROS2 nodes, protocols, and URDF descriptions reside. These packages manage the communication between the hardware (or simulation) and the control policies.
- Robot Protocol Abstractions: Indicate the abstraction layers (robot_protocols) that emulate real robot behavior including latency simulation.

d. Data Generation, Conversion & Visualization:
- Synthetic Data Pipeline: Include a flow showing how recorded episodes in Isaac Sim (controlled from isaac_src and launch-profiles) pass through conversion scripts (invoked via docker/run convert_isaac_to_lerobot) to generate a synthetic dataset.

- Docker containers (deployment layer) launch simulation components and ROS2 nodes.
- ROS2 nodes and ROS messages (from pkgs/myarm_ai_msgs) mediate between the physical/simulated robot and the control logic.
- The synthetic data generation process flows from simulation in Isaac Sim → trajectory recording → domain randomization via the renderer → conversion to a dataset.
- Data flows back into training pipelines (external to this repository) and visualization tools.
- Dependencies, for instance, the teleop profile uses docker/launch scripts to bring up ROS2 nodes that interact with Isaac Sim.

##### Architectural Patterns & Technologies Highlight
- Containerization: The use of Docker ensures loose coupling and easier deployment.
- Modular Design: Separation between simulation (isaac_src, extensions), control (ROS2 nodes in pkgs), and data conversion (scripts and docker/run commands) is evident.
- ROS2 Middleware: Shows the message-passing infrastructure typical for robotics applications.
- Synthetic Data Pipeline: Emphasizes how simulation data is post-processed, randomized, and converted for machine learning tasks.
- CI/CD Integration: Linting, testing workflows (in .github) enforce quality and streamline deployment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Deployment & Orchestration"
        DC["Docker Compose"]:::docker
        DF["Dockerfiles & Utils"]:::docker
        CI["CI/CD & Linting"]:::docker
    end

    subgraph "Simulation & Synthetic Data Generation"
        ISAAC["Isaac Sim Engine & Assets"]:::sim
        TR["Trajectory Recorder & Renderer"]:::sim
    end

    subgraph "ROS2 Middleware & Robot Controllers"
        RP["ROS2 Launch Profiles"]:::ros
        RN["ROS2 Nodes & Robot Protocols"]:::ros
    end

    subgraph "Data Conversion & Visualization"
        DCV["Synthetic Data Converter"]:::data
        GRAF["Grafana Dashboard"]:::data
    end

    %% Relationships
    DC -->|"launches"| ISAAC
    DC -->|"triggers"| RP
    DC -->|"deploys"| GRAF
    ISAAC -->|"records"| TR
    TR -->|"converts"| DCV
    RP -->|"initiates"| RN

    %% Click Events
    click DC "https://github.com/apockill/pi_at_home/blob/main/docker-compose.yaml"
    click DF "https://github.com/apockill/pi_at_home/tree/main/docker"
    click CI "https://github.com/apockill/pi_at_home/tree/main/.github/workflows"
    click ISAAC "https://github.com/apockill/pi_at_home/tree/main/isaac_src/assets"
    click TR "https://github.com/apockill/pi_at_home/tree/main/isaac_src/extensions/trajectory_synth"
    click RP "https://github.com/apockill/pi_at_home/tree/main/launch-profiles/teleop_myarm"
    click RN "https://github.com/apockill/pi_at_home/tree/main/pkgs/myarm_ai"
    click DCV "https://github.com/apockill/pi_at_home/blob/main/pkgs/myarm_ai/myarm_ai/scripts/convert_isaac_to_lerobot.py"
    click GRAF "https://github.com/apockill/pi_at_home/tree/main/docker/grafana"

    %% Styles
    classDef docker fill:#FFCC80,stroke:#333,stroke-width:2px;
    classDef sim fill:#8FBC8F,stroke:#333,stroke-width:2px;
    classDef ros fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef data fill:#DDA0DD,stroke:#333,stroke-width:2px;
```
