# xbyyh/go2-low-friction-locomotion-benchmark architecture

> Architecture diagram of the GitHub repository xbyyh/go2-low-friction-locomotion-benchmark, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/xbyyh/go2-low-friction-locomotion-benchmark
- Repository: https://github.com/xbyyh/go2-low-friction-locomotion-benchmark

## Overview

1. **What this repository is**
   This repo is not a full standalone RL stack; it is an experiment overlay for the original Unitree RL / MuJoCo locomotion project. Its main purpose is to compare a **baseline Go2 policy** against a **slippery-trained robust policy** under flat and low-friction terrain.

2. **Core architectural boundary**
   The real training/runtime code lives in the upstream Unitree RL repository. This repo contributes a small set of **replacement files** that alter:
   - environment configuration,
   - evaluation command generation,
   - evaluation analysis/plotting,
   - and command-set definitions.
   So the boundary is: **upstream RL framework provides training/eval engine; this repo provides task-specific benchmark logic and outputs**.

3. **Configuration subsystem**
   The key config files are:
   - `velocity_env_cfg.py`
   - `env_cfgs.py`
   - `__init__.py`
   
   These adapt the Go2 velocity task configuration. From the README, they are meant to be copied into the upstream `src/tasks/velocity/...` tree. This is where flat vs slippery terrain behavior, friction randomization, and Go2-specific environment variants are defined.

4. **Command/evaluation input subsystem**
   `go2_eval_cmd_set_v1.json` is the fixed evaluation command schedule. It is the input that drives the benchmark’s repeated command sequences, so both policies are tested on the **same command stream** for fair comparison. This is an important data boundary: **command set in, evaluation trajectories out**.

5. **Evaluation runner**
   `eval_fixed_cmd.py` appears to be the script that executes the trained policy against the fixed command set and logs tracking behavior. The README shows it is used for:
   - velocity tracking at multiple linear speeds (`vx`)
   - angular tracking at multiple yaw speeds (`wz`)
   - and the extreme yaw reversal stress test.
   
   Architecturally, this is the stage that sits between trained policy checkpoints and analysis plots.

6. **Analysis and plotting subsystem**
   `analyze_and_plot_eval.py` and `comprehensive_plot.py` are post-processing utilities. They consume evaluation logs and produce the figures shown in the README:
   - per-scenario tracking plots,
   - mean/steady-state error comparisons,
   - and summary charts such as `comprehensive_error_comparison.png`.
   
   This is the repo’s reporting layer: it turns raw eval traces into benchmark evidence.

7. **Experiment branches: baseline vs robust**
   The repository stores two parallel experiment tracks:
   - `baseline_checkpoint` and `baseline/Unitree_Go2_*`
   - `slippery1.0_checkpoint` and `slippery1.0plot/Unitree_Go2_*`
   
   These represent the two policies being compared. The baseline is trained on flat/default conditions, while the robust policy is trained with slippery/friction-randomized terrain. The folder names make the comparison axis explicit: **policy variant × terrain type**.

8. **Checkpoint/artifact layout**
   Each checkpoint directory contains:
   - `model_4800.pt` — the selected PyTorch model checkpoint,
   - `policy.onnx` — exported inference model,
   - `params/agent.yaml` and `params/env.yaml` — run metadata/config snapshot,
   - TensorBoard event files — training curves,
   - `git/unitree_rl_mjlab.diff` — code diff against upstream.
   
   These artifacts show the repo is optimized for **reproducibility and comparison**, not for a generic runtime service.

9. **Training-to-evaluation data flow**
   The lifecycle is:
   1. train PPO policy in the upstream Unitree RL framework,
   2. save checkpoint near peak performance (around 4800 iterations per README),
   3. export or load the checkpoint for evaluation,
   4. run fixed-command tests on flat/slippery terrains,
   5. post-process logs into plots and summary metrics.
   
   That flow is the main architecture diagram you’d want to draw.

10. **Training setup and external dependencies**
    The project depends on the upstream **PPO-based locomotion controller**, **MuJoCo simulation**, and the **Unitree Go2** task definition. The README’s training commands indicate GPU-based training via `CUDA_VISIBLE_DEVICES`, and parallel simulation environments (`--env.scene.num_envs 256`). So the runtime is a **simulation-first RL workload**, not an on-robot deployment stack.

11. **Repository organization as deliverables**
    The top-level files are mostly “benchmark deliverables”:
    - scripts that replace upstream ones,
    - trained checkpoints,
    - generated plots,
    - and the README narrative comparing performance.
    
    In diagram terms, the repo contributes two main outputs: **trained policy artifacts** and **evaluation visualizations**.

12. **Practical architecture summary**
    A concise diagram would show:
    - **Upstream Unitree RL training engine** in the center,
    - **Go2 env/config overrides** feeding it,
    - **fixed command JSON** feeding evaluation,
    - **trained checkpoints** flowing into evaluation,
    - **plotting scripts** consuming logs and producing benchmark figures,
    - and two parallel branches: **baseline** vs **slippery-trained robust**.

Main entry points: [`comprehensive_plot.py`](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/comprehensive_plot.py) (Plotter), [`eval_fixed_cmd.py`](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/eval_fixed_cmd.py) (Eval runner), [`README.md`](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/README.md) (README), [`env_cfgs.py`](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/env_cfgs.py) (Env configs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_overlay["Benchmark overlay"]
  node_n_readme["README<br/>docs<br/>[README.md]"]
  node_n_init["Task init<br/>[__init__.py]"]
  node_n_env_cfgs["Env configs<br/>task config<br/>[env_cfgs.py]"]
  node_n_velocity_cfg["Velocity cfg<br/>task config"]
  node_n_cmdset["Command set<br/>evaluation input"]
  node_n_eval_runner["Eval runner<br/>script<br/>[eval_fixed_cmd.py]"]
  node_n_analysis["Analysis<br/>postprocess"]
  node_n_plotter["Plotter<br/>plot script"]
end

subgraph group_group_artifacts["Policy artifacts"]
  node_n_baseline_ckpt[("Baseline ckpt<br/>policy artifact")]
  node_n_slippery_ckpt[("Slippery ckpt<br/>policy artifact")]
end

subgraph group_group_outputs["Evaluation outputs"]
  node_n_baseline_flat["Baseline flat<br/>benchmark result"]
  node_n_baseline_slippery["Baseline slip<br/>benchmark result"]
  node_n_robust_flat["Robust flat<br/>benchmark result<br/>[Unitree_Go2_Flat]"]
  node_n_robust_slippery["Robust slip<br/>benchmark result"]
end

node_n_upstream["Unitree RL<br/>external framework"]
node_n_mujoco[("MuJoCo<br/>simulator")]

node_n_readme -->|"documents"| node_n_env_cfgs
node_n_readme -->|"defines"| node_n_cmdset
node_n_readme -->|"invokes"| node_n_eval_runner
node_n_readme -->|"reports"| node_n_analysis
node_n_env_cfgs -->|"specializes"| node_n_velocity_cfg
node_n_init -->|"exports"| node_n_env_cfgs
node_n_velocity_cfg -->|"overrides"| node_n_upstream
node_n_env_cfgs -->|"overrides"| node_n_upstream
node_n_upstream -->|"simulates on"| node_n_mujoco
node_n_cmdset -->|"feeds"| node_n_eval_runner
node_n_baseline_ckpt -->|"evaluated by"| node_n_eval_runner
node_n_slippery_ckpt -->|"evaluated by"| node_n_eval_runner
node_n_eval_runner -->|"logs to"| node_n_analysis
node_n_analysis -->|"feeds"| node_n_plotter
node_n_baseline_ckpt -->|"produces"| node_n_baseline_flat
node_n_baseline_ckpt -->|"produces"| node_n_baseline_slippery
node_n_slippery_ckpt -->|"produces"| node_n_robust_flat
node_n_slippery_ckpt -->|"produces"| node_n_robust_slippery
node_n_plotter -->|"compares"| node_n_baseline_flat
node_n_plotter -->|"compares"| node_n_baseline_slippery
node_n_plotter -->|"compares"| node_n_robust_flat
node_n_plotter -->|"compares"| node_n_robust_slippery

click node_n_readme "https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/README.md"
click node_n_init "https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/__init__.py"
click node_n_env_cfgs "https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/env_cfgs.py"
click node_n_velocity_cfg "https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/velocity_env_cfg.py"
click node_n_cmdset "https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/go2_eval_cmd_set_v1.json"
click node_n_eval_runner "https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/eval_fixed_cmd.py"
click node_n_analysis "https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/analyze_and_plot_eval.py"
click node_n_plotter "https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/comprehensive_plot.py"
click node_n_baseline_ckpt "https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/tree/main/baseline_checkpoint"
click node_n_slippery_ckpt "https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/slippery1.0_checkpoint"
click node_n_baseline_flat "https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/tree/main/baseline/Unitree_Go2_Flat"
click node_n_baseline_slippery "https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/tree/main/baseline/Unitree_Go2_Slippery"
click node_n_robust_flat "https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/slippery1.0plot/Unitree_Go2_Flat"
click node_n_robust_slippery "https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/slippery1.0plot/Unitree_Go2_Slippery"

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_n_readme,node_n_init,node_n_env_cfgs,node_n_velocity_cfg,node_n_cmdset,node_n_eval_runner,node_n_analysis,node_n_plotter toneBlue
class node_n_baseline_ckpt,node_n_slippery_ckpt toneAmber
class node_n_baseline_flat,node_n_baseline_slippery,node_n_robust_flat,node_n_robust_slippery toneMint
class node_n_upstream,node_n_mujoco toneNeutral
```

## Components

### Benchmark overlay

Repository files that adapt the upstream Unitree RL Go2 task for the low-friction benchmark.

- [README](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/README.md): docs · Benchmark description, setup, and comparison narrative. · `README.md`
- [Task init](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/__init__.py): module · Package entry used when the upstream task tree imports these overrides. · `__init__.py`
- [Env configs](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/env_cfgs.py): task config · Go2 environment configuration variants and benchmark-specific overrides. · `env_cfgs.py`
- [Velocity cfg](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/velocity_env_cfg.py): task config · Velocity-task configuration tuned for flat vs slippery terrain behavior. · `velocity_env_cfg.py`
- [Command set](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/go2_eval_cmd_set_v1.json): evaluation input · Fixed command schedule used to compare policies under identical motion sequences. · `go2_eval_cmd_set_v1.json`
- [Eval runner](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/eval_fixed_cmd.py): script · Runs trained policies against the fixed command set and collects tracking logs. · `eval_fixed_cmd.py`
- [Analysis](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/analyze_and_plot_eval.py): postprocess · Aggregates evaluation traces into summary metrics and comparisons. · `analyze_and_plot_eval.py`
- [Plotter](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/comprehensive_plot.py): plot script · Builds comprehensive benchmark figures from analysis outputs. · `comprehensive_plot.py`

### Policy artifacts

Saved checkpoints and metadata for the baseline and slippery-trained policies.

- [Baseline ckpt](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/tree/main/baseline_checkpoint): policy artifact · Checkpoint bundle for the flat/default policy variant. · `baseline_checkpoint`
- [Slippery ckpt](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/slippery1.0_checkpoint): policy artifact · Checkpoint bundle for the friction-randomized robust policy variant. · `slippery1.0_checkpoint`

### Evaluation outputs

Generated plots and comparison figures produced from fixed-command evaluation.

- [Baseline flat](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/tree/main/baseline/Unitree_Go2_Flat): benchmark result · Baseline policy results on flat terrain. · `baseline/Unitree_Go2_Flat`
- [Baseline slip](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/tree/main/baseline/Unitree_Go2_Slippery): benchmark result · Baseline policy results on slippery terrain. · `baseline/Unitree_Go2_Slippery`
- [Robust flat](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/slippery1.0plot/Unitree_Go2_Flat): benchmark result · Slippery-trained policy results on flat terrain. · `slippery1.0plot/Unitree_Go2_Flat`
- [Robust slip](https://github.com/xbyyh/go2-low-friction-locomotion-benchmark/blob/main/slippery1.0plot/Unitree_Go2_Slippery): benchmark result · Slippery-trained policy results on slippery terrain. · `slippery1.0plot/Unitree_Go2_Slippery`

### Other components

- **Unitree RL**: external framework · Upstream PPO-based locomotion training and simulation engine.
- **MuJoCo**: simulator · Physics simulation backend used by the locomotion benchmark.

## Connections

- README → Env configs: documents · Explains how the override configs are used in the upstream tree.
- README → Command set: defines · Describes the fixed evaluation command schedule.
- README → Eval runner: invokes · Shows how to run fixed-command evaluation for both policies.
- README → Analysis: reports · Describes the post-processing and comparison workflow.
- Env configs → Velocity cfg: specializes · Task-level environment variants build on the velocity task config.
- Task init → Env configs: exports · Package entry makes the override modules importable.
- Velocity cfg → Unitree RL: overrides · Replacement configuration is copied into the upstream framework.
- Env configs → Unitree RL: overrides · Benchmark-specific environment variants plug into the upstream task code.
- Unitree RL → MuJoCo: simulates on · The locomotion controller runs inside MuJoCo.
- Command set → Eval runner: feeds · Fixed commands drive the evaluation loop.
- Baseline ckpt → Eval runner: evaluated by · Baseline policy checkpoint is loaded for benchmarking.
- Slippery ckpt → Eval runner: evaluated by · Robust policy checkpoint is loaded for benchmarking.
- Eval runner → Analysis: logs to · Evaluation traces are summarized into metrics.
- Analysis → Plotter: feeds · Summary statistics are turned into comparison figures.
- Baseline ckpt → Baseline flat: produces · Baseline checkpoint underlies the flat-terrain result set.
- Baseline ckpt → Baseline slip: produces · Baseline checkpoint underlies the slippery-terrain result set.
- Slippery ckpt → Robust flat: produces · Robust checkpoint underlies the flat-terrain result set.
- Slippery ckpt → Robust slip: produces · Robust checkpoint underlies the slippery-terrain result set.
- Plotter → Baseline flat: compares · Uses the baseline flat result in summary plots.
- Plotter → Baseline slip: compares · Uses the baseline slippery result in summary plots.
- Plotter → Robust flat: compares · Uses the robust flat result in summary plots.
- Plotter → Robust slip: compares · Uses the robust slippery result in summary plots.
