Skip to content

feat: simulation foundation — models, ABC, factory, model registry, assets#84

Open
cagataycali wants to merge 2 commits intostrands-labs:mainfrom
cagataycali:feat/simulation-foundation
Open

feat: simulation foundation — models, ABC, factory, model registry, assets#84
cagataycali wants to merge 2 commits intostrands-labs:mainfrom
cagataycali:feat/simulation-foundation

Conversation

@cagataycali
Copy link
Copy Markdown
Member

TL;DR

Add lightweight simulation framework abstractions: dataclasses, ABC, factory, model registry, and asset manager. No MuJoCo dependency — all pure Python with stdlib + dataclasses.

⚠️ Depends on PR #83 (build system) for [sim] extra and Python ≥3.12

What's in this PR

File Lines What
simulation/models.py 108 Dataclasses: SimWorld, SimRobot, SimObject, SimCamera, TrajectoryStep, SimStatus
simulation/base.py 173 SimulationBackend ABC — interface contract for all backends
simulation/factory.py 191 create_simulation() + pluggable backend registration
simulation/model_registry.py 107 URDF/MJCF path resolution via robot_descriptions + search paths
simulation/__init__.py 131 Package init with lazy imports
assets/__init__.py 282 Asset manager — auto-download robot meshes from MuJoCo Menagerie
assets/download.py 18 Download helper
tools/download_assets.py 493 @tool for asset downloads
tests/test_simulation_foundation.py 338 22 tests covering all modules

Design

# Pure data (no heavy deps)
from strands_robots.simulation import SimWorld, SimRobot, SimObject

# ABC for custom backends
from strands_robots.simulation.base import SimulationBackend

# Factory with pluggable backends
from strands_robots.simulation import create_simulation, register_backend
sim = create_simulation(backend="mujoco")  # will work after PR4

The ABC defines 12 abstract methods (create_world, step, add_robot, render, etc.) plus optional methods with default no-op implementations (run_policy, randomize, get_contacts). Context manager protocol included.

Testing

  • ✅ 22 new tests: dataclass defaults, ABC contracts, factory registration, model registry resolution
  • ✅ 288 total tests pass (266 existing + 22 new)
  • ✅ Lint clean
  • ✅ No import mujoco anywhere in this PR

Part 3 of 6 in the MuJoCo simulation PR decomposition

- Bump requires-python from >=3.10 to >=3.12
- Move opencv-python-headless and Pillow to [sim] extra
- Add [sim] extra: mujoco, robot_descriptions, opencv, Pillow
- Add .python-version (3.12)
- Add uv.lock for deterministic builds
- Switch CI from hatch to uv
- Add libosmesa6-dev to CI for MuJoCo headless rendering
- Remove hatch env scripts (use uv run directly)
- Remove --cov from pytest addopts (run coverage explicitly)
- Update ruff target-version and mypy python_version to 3.12
- Trim pyproject.toml comments for readability

Why Python 3.12+: match statements, type aliases, ExceptionGroup
patterns used in upcoming simulation code. MuJoCo 3.x works best
with 3.12+. No users have reported needing 3.10/3.11 support.

Why move opencv/Pillow to [sim]: core strands-robots (hardware
control only) shouldn't require heavy image processing deps.
…ssets

Add the lightweight simulation framework abstractions:

- simulation/models.py: Dataclasses (SimWorld, SimRobot, SimObject,
  SimCamera, TrajectoryStep, SimStatus) — pure data, no physics deps
- simulation/base.py: SimulationBackend ABC defining the contract
  all backends (MuJoCo, Isaac, Newton) must implement
- simulation/factory.py: create_simulation() + pluggable backend
  registration system
- simulation/model_registry.py: URDF/MJCF path resolution via
  robot_descriptions package + search paths + custom registration
- assets/: Asset manager for auto-downloading robot meshes from
  MuJoCo Menagerie on first use
- tools/download_assets.py: @tool for asset downloads
- tests/test_simulation_foundation.py: 22 tests covering dataclasses,
  ABC instantiation/contracts, factory registration, model registry

No MuJoCo import required — all abstractions are lightweight.
ref: ${{ inputs.ref }}
persist-credentials: false

- name: Install uv
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when PR #83 merged this lines will disappear during rebase ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

1 participant