Skip to main content

myoassist.terrains

Modular procedural terrain generator for MuJoCo, designed to be used by MyoAssist and other musculoskeletal-simulation projects within MyoSuite.

myoassist_terrains turns a small JSON description into a ready-to-include MuJoCo MJCF fragment. Two kinds of terrain are supported:

  • a uniform surface: one plane or one heightfield (flat, slope, random, sinusoidal), suited to steady-state locomotion;
  • a grid: a tiled course built from nine tile types, with explicit per-cell placement, weighted-random sampling, parametric variation of every tile, and a shared texture for uniform-palette renders.

It also answers where the ground is. surface_height_at(config, x, y) reports the walkable surface height from the config alone, so a consumer placing something on the terrain does not have to collision-probe a compiled model for it.

┌──────────────────────────────────────────────────────────────────┐
│  JSON config  ──►  build_terrain()  ──►  MjSpec  ──►  XML include│
│                       (Python API)          (compose)    (CLI)   │
└──────────────────────────────────────────────────────────────────┘

Getting started

Installation

git clone https://github.com/neumovelab/myoassist.terrains.git
cd myoassist.terrains
pip install -e .

# Optional extras
pip install -e ".[render]"   # adds mediapy for ensemble renders
pip install -e ".[dev]"      # adds pytest and ruff

Requires Python >=3.10 and mujoco>=3.3.3.

Quick start

The shortest config is a uniform terrain:

{ "terrain": "slope", "terrain_name": "gentle_climb", "deg": 8.0 }

A tiled course names its cells:

{
  "terrain_name": "first_terrain",
  "grid":   { "rows": 2, "cols": 2, "tile_size": [10.0, 10.0] },
  "border": { "width": 0.5, "match_mode": "min" },
  "palette_preset": "diverse",
  "tiles": [
    { "row": 0, "col": 0, "type": "flat",   "params": { "height": 0.0 } },
    { "row": 0, "col": 1, "type": "stairs", "params": { "n_steps": 6, "step_height": 0.18 } },
    { "row": 1, "col": 0, "type": "slope",  "params": { "angle_deg": 18.0 } },
    { "row": 1, "col": 1, "type": "rough",  "params": { "seed": 42, "vertical_relief": 0.8 } }
  ]
}

Build it from a project that contains a terrain_config.xml pointer:

cd my_user_project        # contains terrain_config.xml + terrain_style.xml
myoassist-terrains build path/to/first_terrain.json --activate

The CLI writes terrain/first_terrain.xml into the project and, with --activate, updates the <include file="terrain/first_terrain.xml"/> line in terrain_config.xml. Any model that includes terrain_config.xml then sees the new terrain. Use --root <dir> to build into a project from elsewhere.

Preview it without a user model:

myoassist-terrains preview first_terrain
python -m mujoco.viewer --mjcf=terrain/first_terrain_preview.xml

Contents

Documentation here is the developer reference. The narrative version, with figures, is on the MyoAssist site.

Changes, including the ones that alter emitted geometry, are recorded in CHANGELOG.md.


License

Apache 2.0. See LICENSE.

Metadata

Release files for myoassist-terrains 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for myoassist-terrains 1.0.0
File Size Uploaded
myoassist_terrains-1.0.0.tar.gz 90.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for myoassist-terrains 1.0.0
File Interpreter ABI Platform
myoassist_terrains-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 174.0 kB

Release files / myoassist_terrains-1.0.0.tar.gz

Download URL myoassist_terrains-1.0.0.tar.gz
Size 90.9 kB
Tags Source
SHA-256 checksum
How to use checksums
61a8b854c2e59213ee0353710d9e06c03333f248757c638f1241727ca42355d5
BLAKE2b-256 checksum
How to use checksums
9bc7ec5db0d7158374577124259e07a5d9b8381a810c75b149c04485105f342c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 19, 2026.

Transparency log

Release files / myoassist_terrains-1.0.0-py3-none-any.whl

Download URL myoassist_terrains-1.0.0-py3-none-any.whl
Size 83.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
836298327490e3cad5bf880c7f9b80bbe12d6a9c4369390cde6e17a3b0a171cb
BLAKE2b-256 checksum
How to use checksums
3939068347459bf185bb39f4148ec3fa5b2269122516344fc45b875d8e2a8162
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page