# iminthemiddle/emloco architecture

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

- Interactive diagram: https://gitdiagram.com/iminthemiddle/emloco
- Repository: https://github.com/iminthemiddle/emloco

## Overview

##### Data Preparation & Ingestion
- Datasets: Multiple datasets (from JRDB, JTA, and keypoints from human-scene-transformer) are required. These are either preprocessed or fed into training modules.
- Preprocessing utilities: Scripts in EqMotion, in pacer, and poselib perform tasks such as pose conversion and dataset preparation.
- Configuration files: YAML configs for PACER’s policy training and Social-Transmotion training (e.g. pacer/pacer/data/cfg/* and social-transmotion/configs/*).

##### Physics Simulation & Locomotion Generation Module
- IsaacGym / PACER environment: The pacer and isaacgym directories include scripts, assets, and docker configurations for running physics simulation. This module contains:
- Pretraining of the locomotion generation policy network.
- Training a Locomotion Value function (LocoVal) using a physics simulator.
- Data flow: The simulator produces policy weights and gradients; then the LocoVal function evaluation is used to assess physical plausibility.

##### Human Trajectory Prediction Module
- Social-Transmotion and EqMotion parts: The Social-Transmotion subproject (with train_jta.py, evaluate_jta.py, visualize_pred.py, etc.) implements the trajectory prediction network incorporating:
- EmLoco loss into training.
- Multi-head prediction options (indicated by flags such as “--multi_modal”).
- Interactions: The LocoVal function trained by the PACER module is used to filter or influence trajectory predictions.
- Utilities: Supporting scripts and configuration files (in social-transmotion/configs and utilities) assist in the evaluation and visualization of outputs.

##### Pose Conversion and Skeleton Utilities
- Poselib: Contains utilities for 3D pose conversions, rotation math, and skeleton visualization.
- Role: Convert raw or tracked human pose data into SMPL (or other differentiable representations) which then feed into the trajectory prediction module.

##### Training & Evaluation Pipelines
- Separate entry points for training the locomotion simulation (pacer/run.py), training the trajectory prediction network (train_jta.py), and evaluation/visualization (evaluate_jta.py, visualize_pred.py).

- Data Ingestion/Preparation (data sources, preprocessing, configuration).
- Simulation & Locomotion Module (physics engine, policy pretraining, LocoVal training).
- Trajectory Prediction Module (the predictor network with the EmLoco loss, multi-head architecture).
- Auxiliary Pose Conversion and Visualization (poselib, EqMotion visualization tools).
– “Data & Datasets” for the input pipelines.
– “Physics Simulator (PACER/IsaacGym)” representing the locomotion generation environment.
– “Locomotion Value Function (LocoVal)” as part of the simulation evaluation.
– “Trajectory Predictor (Social-Transmotion/EqMotion)” with EmLoco loss integration.
– “Pose Conversion Utilities (Poselib)” for the conversion and visualization of poses and skeleton data.
– From Data Preparation to both the Simulator and Predictor.
– From the Simulator (policy networks and LocoVal evaluations) feeding into the training loop of the predictor.
- Environment boundaries or grouping:
– Separate “virtual environments” or “containers” (as noted, different conda environments for PACER, Social-Transmotion, and Pose to SMPL) to highlight modular separations.

Additional Considerations:
- External dependencies such as pre-trained model data and dataset downloads.
- If needed, include development/deployment scripts and docker setups (e.g., in the isaacgym/docker folder) to account for infrastructure.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Data Preparation & Ingestion
    subgraph "Data Preparation & Ingestion"
        D1["Datasets & Preprocessing"]:::data
        D2["Pacer YAML Configs"]:::data
        D3["Social-Transmotion Configs"]:::data
        D1 --> D2
        D1 --> D3
    end

    %% PACER/IsaacGym Environment
    subgraph "PACER/IsaacGym Environment"
        P1["Physics Simulation"]:::simulation
        P2["IsaacGym Engine"]:::simulation
        P3["Pacer Simulation Training"]:::simulation
        P4["LocoVal Evaluation"]:::simulation
        P1 --> P2
        P1 --> P3
        P3 --> P4
    end

    %% Social-Transmotion Environment
    subgraph "Social-Transmotion Environment"
        T1["Trajectory Predictor (EmLoco Loss)"]:::prediction
        T2["Trajectory Evaluation & Visualization"]:::prediction
        T1 --> T2
    end

    %% Pose Conversion Environment
    subgraph "Pose Conversion Environment"
        U1["Pose Conversion Utilities (Poselib)"]:::utility
    end

    %% Cross-group Data Flows
    D1 -->|"preprocessed_data"| P3
    D1 -->|"config_data"| T1
    D1 -->|"raw_data"| U1
    U1 -->|"pose_conversion"| T1
    P4 -->|"plausibility_feedback"| T1

    %% Click Events
    click D2 "https://github.com/iminthemiddle/emloco/tree/main/pacer/pacer/data/cfg"
    click D3 "https://github.com/iminthemiddle/emloco/tree/main/social-transmotion/configs"
    click P2 "https://github.com/iminthemiddle/emloco/tree/main/isaacgym/"
    click P3 "https://github.com/iminthemiddle/emloco/tree/main/pacer/pacer/"
    click T1 "https://github.com/iminthemiddle/emloco/tree/main/social-transmotion/"
    click U1 "https://github.com/iminthemiddle/emloco/tree/main/pacer/poselib/"
    click T2 "https://github.com/iminthemiddle/emloco/blob/main/social-transmotion/evaluate_jta.py"

    %% Styles
    classDef data fill:#F5CBA7,stroke:#9C640C,stroke-width:2px;
    classDef simulation fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef prediction fill:#A9DFBF,stroke:#1E8449,stroke-width:2px;
    classDef utility fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
```
