# abusumon/morphological-and-control-evolution architecture

> Architecture diagram of the GitHub repository abusumon/morphological-and-control-evolution, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abusumon/morphological-and-control-evolution
- Repository: https://github.com/abusumon/morphological-and-control-evolution

## Overview

This repository evolves a quadruped gait, leg length, and steering controller to push a box into a goal. The user-facing workflow is Stage 2 evolution: seed a population with Stage 1 locomotion results, score genomes on training spawns through simulated episodes, and periodically assess held-out spawns. Internally, each episode combines the push-state controller with a CPG and PyBullet robot model; fitness aggregates per-spawn outcomes. Edges reflect the excerpts, source index, and README; unsampled implementation details are not inferred.

Main entry points: [`pushbox/stage2.py`](https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/stage2.py) (Push evolution), [`pushbox/evaluate.py`](https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/evaluate.py) (Episode simulation), [`pushbox/body.py`](https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/body.py) (Robot and world), [`pushbox/pretrain_locomotion.py`](https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/pretrain_locomotion.py) (Locomotion pretraining)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Evolution stages"]
  node_cli["CLI entry<br/>[main.py]"]
  node_stage2["Push evolution<br/>[stage2.py]"]
  node_pretrain["Locomotion pretraining"]
  node_ga["Memetic GA<br/>[ga_core.py]"]
  node_genome["Genome operators<br/>[genome.py]"]
end

subgraph group_task["Push-task evaluation"]
  node_spawns["Spawn sets<br/>[spawns.py]"]
  node_episode["Episode simulation<br/>[evaluate.py]"]
  node_fitness["Fitness scoring<br/>[fitness.py]"]
end

subgraph group_model["Robot and control"]
  node_controller["Push controller<br/>[controller.py]"]
  node_cpg["CPG locomotion<br/>[cpg.py]"]
  node_body["Robot and world<br/>[body.py]"]
end

subgraph group_support["Experiment support"]
  node_config["Task configuration<br/>[config.py]"]
  node_runio["Run state and logs<br/>[runio.py]"]
end

node_user(("Researcher"))
node_physics["PyBullet"]

node_user -->|"starts run"| node_cli
node_cli -->|"dispatches"| node_stage2
node_stage2 -->|"runs seeds"| node_pretrain
node_stage2 -->|"evolves population"| node_ga
node_stage2 -->|"selects spawns"| node_spawns
node_stage2 -->|"scores episodes"| node_episode
node_stage2 -->|"scores outcomes"| node_fitness
node_stage2 -->|"saves run state"| node_runio
node_pretrain -->|"tests locomotion"| node_episode
node_pretrain -->|"evolves gaits"| node_ga
node_pretrain -->|"writes seeds"| node_runio
node_ga -->|"uses operators"| node_genome
node_episode -->|"builds world"| node_body
node_episode -->|"requests actions"| node_controller
node_episode -->|"computes targets"| node_cpg
node_body -->|"creates bodies"| node_physics
node_episode -->|"steps simulation"| node_physics
node_genome -->|"uses leg names"| node_body
node_cpg -->|"uses joint names"| node_body
node_controller -->|"reads thresholds"| node_config
node_body -->|"reads physics settings"| node_config
node_cpg -->|"reads gait settings"| node_config

click node_cli "https://github.com/abusumon/morphological-and-control-evolution/blob/main/main.py"
click node_stage2 "https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/stage2.py"
click node_pretrain "https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/pretrain_locomotion.py"
click node_ga "https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/ga_core.py"
click node_genome "https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/genome.py"
click node_spawns "https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/spawns.py"
click node_episode "https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/evaluate.py"
click node_fitness "https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/fitness.py"
click node_controller "https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/controller.py"
click node_cpg "https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/cpg.py"
click node_body "https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/body.py"
click node_config "https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/config.py"
click node_runio "https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/runio.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_cli,node_stage2,node_pretrain,node_ga,node_genome toneBlue
class node_spawns,node_episode,node_fitness toneAmber
class node_controller,node_cpg,node_body toneMint
class node_config,node_runio toneRose
class node_user,node_physics toneIndigo
```

## Components

### Evolution stages

- [CLI entry](https://github.com/abusumon/morphological-and-control-evolution/blob/main/main.py): `main.py`
- [Push evolution](https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/stage2.py): `pushbox/stage2.py`
- [Locomotion pretraining](https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/pretrain_locomotion.py): `pushbox/pretrain_locomotion.py`
- [Memetic GA](https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/ga_core.py): `pushbox/ga_core.py`
- [Genome operators](https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/genome.py): `pushbox/genome.py`

### Push-task evaluation

- [Spawn sets](https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/spawns.py): `pushbox/spawns.py`
- [Episode simulation](https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/evaluate.py): `pushbox/evaluate.py`
- [Fitness scoring](https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/fitness.py): `pushbox/fitness.py`

### Robot and control

- [Push controller](https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/controller.py): `pushbox/controller.py`
- [CPG locomotion](https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/cpg.py): `pushbox/cpg.py`
- [Robot and world](https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/body.py): `pushbox/body.py`

### Experiment support

- [Task configuration](https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/config.py): `pushbox/config.py`
- [Run state and logs](https://github.com/abusumon/morphological-and-control-evolution/blob/main/pushbox/runio.py): `pushbox/runio.py`

### Other components

- **Researcher**
- **PyBullet**

## Connections

- Researcher → CLI entry: starts run (evidence: `README.md`)
- CLI entry → Push evolution: dispatches (evidence: `main.py`)
- Push evolution → Locomotion pretraining: runs seeds (evidence: `pushbox/stage2.py`)
- Push evolution → Memetic GA: evolves population (evidence: `pushbox/stage2.py`)
- Push evolution → Spawn sets: selects spawns (evidence: `pushbox/stage2.py`)
- Push evolution → Episode simulation: scores episodes (evidence: `pushbox/stage2.py`)
- Push evolution → Fitness scoring: scores outcomes (evidence: `pushbox/stage2.py`)
- Push evolution → Run state and logs: saves run state (evidence: `pushbox/stage2.py`)
- Locomotion pretraining → Episode simulation: tests locomotion (evidence: `pushbox/pretrain_locomotion.py`)
- Locomotion pretraining → Memetic GA: evolves gaits (evidence: `pushbox/pretrain_locomotion.py`)
- Locomotion pretraining → Run state and logs: writes seeds (evidence: `pushbox/pretrain_locomotion.py`)
- Memetic GA → Genome operators: uses operators (evidence: `pushbox/ga_core.py`)
- Episode simulation → Robot and world: builds world (evidence: `pushbox/evaluate.py`)
- Episode simulation → Push controller: requests actions (evidence: `pushbox/evaluate.py`)
- Episode simulation → CPG locomotion: computes targets (evidence: `pushbox/evaluate.py`)
- Robot and world → PyBullet: creates bodies (evidence: `pushbox/body.py`)
- Episode simulation → PyBullet: steps simulation (evidence: `pushbox/evaluate.py`)
- Genome operators → Robot and world: uses leg names (evidence: `pushbox/genome.py`)
- CPG locomotion → Robot and world: uses joint names (evidence: `pushbox/cpg.py`)
- Push controller → Task configuration: reads thresholds (evidence: `pushbox/controller.py`)
- Robot and world → Task configuration: reads physics settings (evidence: `pushbox/body.py`)
- CPG locomotion → Task configuration: reads gait settings (evidence: `pushbox/cpg.py`)
