This project is currently in an early prototype stage.
Features, architecture, and documentation are actively evolving, and breaking changes are likely as we iterate.
Weβre building this openly with the community, so feedback, ideas, and contributions are highly encouraged! If youβd like to help shape the direction of the project:
Open an issue to share suggestions or report bugs Start a discussion about improvements Submit a pull request with enhancements Thank you for helping us improve this project!
Integration package for using MyoSuite environments with mjlab's training infrastructure.
- β Automatic Registration: All MyoSuite environments are automatically registered with mjlab
- β MJX/Warp Support: Compatible with both standard MyoSuite and mjx/warp GPU-accelerated versions
- β Native mjlab Integration: Uses mjlab's native task registration when available
- β Backward Compatible: Falls back to gymnasium registry if mjlab native registration unavailable
- β Full Test Coverage: Comprehensive unit tests for all functionality
# Install mjlab-myosuite
pip install -e .
pip install "myosuite @ git+https://github.com/MyoHub/myosuite.git@mjx"
# Or with uv (faster)
uv venv
uv pip install -e .
uv pip install "myosuite @ git+https://github.com/MyoHub/myosuite.git@mjx"import gymnasium as gym
import mjlab_myosuite # Auto-registers all MyoSuite environments
# Create a MyoSuite environment wrapped for mjlab
env = gym.make("Mjlab-MyoSuite-myoElbowPose1D6MRandom-v0")
obs, info = env.reset()
action = env.action_space.sample()
obs, rewards, dones, extras = env.step(action)
env.close()Use the mjlab training scripts:
# Train a policy
uv run train Mjlab-MyoSuite-myoElbowPose1D6MRandom-v0 \
--agent.max-iterations 200 \
--agent.num-steps-per-env 512
# Play with trained policy
uv run play Mjlab-MyoSuite-myoElbowPose1D6MRandom-v0 \
--checkpoint_file logs/rsl_rl/myosuite/.../model_199.ptFor registering specific tasks with custom configurations, see:
examples/example_task_registration.py- Complete example following mjlab's tutorial pattern
The integration follows mjlab's native task registration pattern from the create_new_task tutorial:
βββββββββββββββββββββββββββββββββββββββ
β mjlab Training Pipeline β
β (PPO, WandB, etc.) β
ββββββββββββββββ¬βββββββββββββββββββββββ
β
ββββββββββββββββΌβββββββββββββββββββββββ
β MyoSuite Wrapper β
β - Adapts Gym API to mjlab β
β - Handles batched operations β
ββββββββββββββββ¬βββββββββββββββββββββββ
β
ββββββββββββββββΌβββββββββββββββββββββββ
β MyoSuite (Standard or MJX/Warp) β
β - Musculoskeletal models β
β - Task-specific rewards β
βββββββββββββββββββββββββββββββββββββββ
- Standard MyoSuite: CPU-based MuJoCo simulation
- MJX/Warp MyoSuite: GPU-accelerated from the mjx branch
The wrapper automatically detects and supports both versions.
from mjlab_myosuite.config import MyoSuiteEnvCfg
cfg = MyoSuiteEnvCfg()
cfg.num_envs = 4096 # For training
cfg.device = "cuda:0" # Use GPU for mjx/warp versionsfrom mjlab_myosuite.config import get_default_myosuite_rl_cfg
rl_cfg = get_default_myosuite_rl_cfg()
rl_cfg.max_iterations = 2000
rl_cfg.algorithm.learning_rate = 3e-4TBD
MyoSuite environments support ONNX model export for deployment and inference. The MyoSuiteOnPolicyRunner automatically exports ONNX models when using wandb logging:
from mjlab_myosuite.rl.runner import MyoSuiteOnPolicyRunner
# During training, ONNX models are automatically exported
runner = MyoSuiteOnPolicyRunner(env, agent_cfg, log_dir, device)
runner.learn(num_learning_iterations=1000)
# ONNX model is saved alongside the PyTorch checkpointThe exported ONNX model includes:
- Policy network (actor) with optional observation normalizer
- MyoSuite-specific metadata (action dimensions, observation dimensions, etc.)
- Compatibility with ManagerBasedRlEnv structure
MyoSuite tracking tasks follow the same structure as mjlab's tracking tasks, allowing you to train policies to track reference motions. The tracking functionality is implemented in src/mjlab_myosuite/tasks/tracking/ following the mjlab tracking structure.
from mjlab_myosuite.tasks.tracking.tracking_env_cfg import MyoSuiteTrackingEnvCfg
# Create tracking configuration
cfg = MyoSuiteTrackingEnvCfg()
cfg.num_envs = 4096
cfg.device = "cuda:0"
cfg.commands.motion.motion_file = "path/to/motion.npz"# Train with motion file from wandb artifact
uv run train Mjlab-MyoSuite-Tracking-myoElbowPose1D6MRandom-v0 \
--motion-file examples/elbow_sinusoidal_motion.npz \
--agent.max-iterations 10000# Play with motion file
uv run play Mjlab-MyoSuite-Tracking-myoElbowPose1D6MRandom-v0 \
--checkpoint_file logs/rsl_rl/myosuite/.../model_2000.pt \
--motion-file path/to/motion.npzThe tracking runner (MyoSuiteMotionTrackingOnPolicyRunner) extends the base MyoSuite runner and provides support for motion tracking, including wandb artifact integration for motion files.
The playback_with_viser utility provides a convenient way to visualize policy execution using the Viser web-based viewer:
from scripts.play import playback_with_viser
import gymnasium as gym
# Create environment and policy
env = gym.make("Mjlab-MyoSuite-myoElbowPose1D6MRandom-v0")
policy = load_policy("path/to/checkpoint.pt")
# Playback with Viser
playback_with_viser(env, policy, verbose=True)You can also use it from the command line:
# Use Viser viewer explicitly
play Mjlab-MyoSuite-myoElbowPose1D6MRandom-v0 \
--viewer viser \
--checkpoint_file logs/rsl_rl/myosuite/.../model_2000.pt
# Specify Viser server port
play Mjlab-MyoSuite-myoElbowPose1D6MRandom-v0 \
--viewer viser \
--viser-port 8080 \
--checkpoint_file logs/rsl_rl/myosuite/.../model_2000.pt# Run all tests
pytest tests/
# Run specific test
pytest tests/test_myosuite_integration.py::test_wrapper_creation_direct
# Run GPU acceleration tests (requires CUDA)
pytest tests/test_gpu_acceleration.py -v
# Run ONNX export tests (requires ONNX)
pytest tests/test_onnx_export.py -vRun tests:
make test # Run all tests
make test-fast # Skip slow integration tests
uv run --no-default-groups --group cu128 --group dev pyright
uv run --no-default-groups --group cu128 --group dev pytestFormat code:
uvx pre-commit install
make format- mjlab Tutorial - Official mjlab task creation tutorial
- MyoSuite Documentation - MyoSuite documentation