# langchengg/rl-agibot-x2 architecture

> Architecture diagram of the GitHub repository langchengg/rl-agibot-x2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/langchengg/rl-agibot-x2
- Repository: https://github.com/langchengg/rl-agibot-x2

## Overview

AgiBot X2 Ground Recovery is a MuJoCo/Gymnasium supine-recovery controller, with a ROS 2 runtime using the same frozen controller bundle. The primary workflow loads controller inputs, simulates a recovery, and judges stable standing and safety constraints; PPO training and reference-motion search support controller development. Evaluation, strict reproduction, diagnostics, and ROS telemetry are distinct supporting capabilities. The README documents these capabilities, but sampled source excerpts are sparse, so uncertain internal call relationships are omitted.

Main entry points: [`src/x2_recovery/x2_recovery/env.py`](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/env.py) (Recovery environment), [`src/x2_recovery/x2_recovery/recovery_node.py`](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/recovery_node.py) (Recovery ROS node), [`src/x2_recovery/x2_recovery/model.py`](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/model.py) (Robot model), [`src/x2_recovery/x2_recovery/train.py`](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/train.py) (PPO training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Recovery runtime"]
  node_environment["Recovery environment<br/>[env.py]"]
  node_model["Robot model<br/>[model.py]"]
  node_reset["Pose reset<br/>[reset.py]"]
  node_baseline["Scripted baseline<br/>[baseline.py]"]
  node_success["Success tracking<br/>[success.py]"]
end

subgraph group_learning["Controller development"]
  node_training["PPO training<br/>[train.py]"]
  node_motion["Reference search<br/>[motion_search.py]"]
end

subgraph group_evaluation["Evaluation and audit"]
  node_reproduce["Strict reproduction<br/>[reproduce.py]"]
  node_evaluation["Policy evaluation<br/>[evaluate.py]"]
  node_diagnostics["Diagnostics<br/>[diagnostics.py]"]
  node_model_audit["Model audit<br/>[model_audit.py]"]
  node_constraints["Constraint audit"]
  node_simulation_validation["Simulation validation"]
  node_success_validation["Success validation"]
end

subgraph group_ros["ROS integration"]
  node_recovery_node["Recovery ROS node<br/>[recovery_node.py]"]
  node_telemetry["Telemetry node<br/>[telemetry_node.py]"]
  node_launch["ROS launch<br/>[recovery.launch.py]"]
end

node_operator(("Operator"))
node_robot_assets["X2 robot assets"]

node_operator -->|"requests replay"| node_reproduce
node_reproduce -->|"runs episode"| node_evaluation
node_evaluation -->|"simulates recovery"| node_environment
node_environment -->|"uses model"| node_model
node_model -->|"loads assets"| node_robot_assets
node_environment -->|"resets pose"| node_reset
node_environment -->|"checks standing"| node_success
node_operator -->|"trains policy"| node_training
node_training -->|"trains in"| node_environment
node_operator -->|"searches references"| node_motion
node_motion -->|"tests candidates"| node_environment
node_operator -->|"starts recovery"| node_recovery_node
node_launch -->|"launches"| node_recovery_node
node_recovery_node -->|"runs controller"| node_environment
node_recovery_node -.->|"selects debug mode"| node_baseline
node_telemetry -->|"observes runtime"| node_environment
node_operator -->|"requests analysis"| node_diagnostics
node_operator -->|"audits model"| node_model_audit
node_operator -->|"audits constraints"| node_constraints
node_operator -->|"validates simulation"| node_simulation_validation
node_operator -->|"validates success"| node_success_validation

click node_reproduce "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/reproduce.py"
click node_environment "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/env.py"
click node_model "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/model.py"
click node_reset "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/reset.py"
click node_baseline "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/baseline.py"
click node_success "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/success.py"
click node_training "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/train.py"
click node_motion "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/motion_search.py"
click node_evaluation "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/evaluate.py"
click node_diagnostics "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/diagnostics.py"
click node_model_audit "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/model_audit.py"
click node_constraints "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/constraint_audit.py"
click node_simulation_validation "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/simulation_validation.py"
click node_success_validation "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/success_validation.py"
click node_recovery_node "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/recovery_node.py"
click node_telemetry "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/telemetry_node.py"
click node_launch "https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/launch/recovery.launch.py"

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_environment,node_model,node_reset,node_baseline,node_success toneBlue
class node_training,node_motion toneAmber
class node_reproduce,node_evaluation,node_diagnostics,node_model_audit,node_constraints,node_simulation_validation,node_success_validation toneMint
class node_recovery_node,node_telemetry,node_launch toneRose
class node_operator,node_robot_assets toneIndigo
```

## Components

### Recovery runtime

- [Recovery environment](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/env.py): `src/x2_recovery/x2_recovery/env.py`
- [Robot model](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/model.py): `src/x2_recovery/x2_recovery/model.py`
- [Pose reset](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/reset.py): `src/x2_recovery/x2_recovery/reset.py`
- [Scripted baseline](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/baseline.py): `src/x2_recovery/x2_recovery/baseline.py`
- [Success tracking](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/success.py): `src/x2_recovery/x2_recovery/success.py`

### Controller development

- [PPO training](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/train.py): `src/x2_recovery/x2_recovery/train.py`
- [Reference search](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/motion_search.py): `src/x2_recovery/x2_recovery/motion_search.py`

### Evaluation and audit

- [Strict reproduction](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/reproduce.py): `src/x2_recovery/x2_recovery/reproduce.py`
- [Policy evaluation](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/evaluate.py): `src/x2_recovery/x2_recovery/evaluate.py`
- [Diagnostics](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/diagnostics.py): `src/x2_recovery/x2_recovery/diagnostics.py`
- [Model audit](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/model_audit.py): `src/x2_recovery/x2_recovery/model_audit.py`
- [Constraint audit](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/constraint_audit.py): `src/x2_recovery/x2_recovery/constraint_audit.py`
- [Simulation validation](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/simulation_validation.py): `src/x2_recovery/x2_recovery/simulation_validation.py`
- [Success validation](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/success_validation.py): `src/x2_recovery/x2_recovery/success_validation.py`

### ROS integration

- [Recovery ROS node](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/recovery_node.py): `src/x2_recovery/x2_recovery/recovery_node.py`
- [Telemetry node](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/x2_recovery/telemetry_node.py): `src/x2_recovery/x2_recovery/telemetry_node.py`
- [ROS launch](https://github.com/langchengg/rl-agibot-x2/blob/main/src/x2_recovery/launch/recovery.launch.py): `src/x2_recovery/launch/recovery.launch.py`

### Other components

- **Operator**
- **X2 robot assets**

## Connections

- Operator → Strict reproduction: requests replay
- Strict reproduction → Policy evaluation: runs episode
- Policy evaluation → Recovery environment: simulates recovery
- Recovery environment → Robot model: uses model
- Robot model → X2 robot assets: loads assets
- Recovery environment → Pose reset: resets pose
- Recovery environment → Success tracking: checks standing
- Operator → PPO training: trains policy
- PPO training → Recovery environment: trains in
- Operator → Reference search: searches references
- Reference search → Recovery environment: tests candidates
- Operator → Recovery ROS node: starts recovery
- ROS launch → Recovery ROS node: launches
- Recovery ROS node → Recovery environment: runs controller
- Recovery ROS node → Scripted baseline: selects debug mode
- Telemetry node → Recovery environment: observes runtime
- Operator → Diagnostics: requests analysis
- Operator → Model audit: audits model
- Operator → Constraint audit: audits constraints
- Operator → Simulation validation: validates simulation
- Operator → Success validation: validates success
