MuJoCo Workspace
- mj_ws repo: https://github.com/ispaik06/mj_ws
mj_ws
A lightweight MuJoCo RL workspace inspired by the IsaacLab workflow.
- Keep shared tooling and templates in this repo (
tools/,templates/). - Create project folders under
projects/using a single command. Each project is a self-contained package (editable install) with:
source/envs/(Gymnasium env registration + implementation)scripts/train.py/scripts/play.pylogs/output directory (checkpoints, videos, TensorBoard)
Workspace Layout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
mj_ws/
├─ templates/
│ └─ mujoco_sb3_base/ # project template
│ ├─ source/
│ │ ├─ envs/
│ │ │ ├─ __init__.py # env registration template
│ │ │ └─ env_template.py # env implementation template
│ │ ├─ assets/
│ │ │ └─ humanoid.xml # example MuJoCo XML (optional)
│ │ └─ __init__.py
│ ├─ scripts/
│ │ ├─ train.py # PPO training template
│ │ └─ play.py # playback template
│ └─ README.md # per-project README template
├─ tools/
│ └─ new_project.sh # create a new project from a template
├─ projects/ # generated projects live here
└─ README.md
Prerequisites / Installation
Recommended: create a dedicated Conda environment for this workspace.
0) Create & activate environment
1
2
conda create -n mujoco python=3.11 -y
conda activate mujoco
1) Install system/graphics dependencies (Conda)
1
2
conda install -c conda-forge glfw -y
conda install -c conda-forge pyopengl -y
2) Install Python packages
1
2
3
4
5
6
pip install -U pip
pip install mujoco gymnasium
python -m pip install stable-baselines3 "gymnasium[mujoco]"
pip install tensorboard
3) Install PyTorch (CPU build)
1
python -m pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
If you want GPU acceleration, install a CUDA-enabled PyTorch build that matches your OS/CUDA setup instead of the CPU build above.
Quick Start
1) Create a new project
From the workspace root:
1
./tools/new_project.sh MyHumanoid
This creates:
1
projects/myhumanoid/
The generator auto-synchronizes:
- env file name (
source/envs/myhumanoid.py) - env class name (e.g.,
MyHumanoidEnv) - env id (e.g.,
myhumanoid-v0) scripts/train.py/scripts/play.pyuse the same env id
2) Install the project (editable)
1
2
cd projects/myhumanoid
pip install -e .
3) Train
1
python scripts/train.py
4) Play (render the latest run)
1
python scripts/play.py
How Projects Work
Each generated project is a Python package installed in editable mode (pip install -e .).
- You can
import envsandgym.make(ENV_ID)from anywhere - Changes in
source/are reflected immediately (no reinstall) - If you delete the project folder without uninstalling, you may leave a “broken editable install”
To remove a project cleanly:
1
2
pip uninstall <project_package_name>
rm -rf projects/<project_slug>
Where Logs Go
Training writes outputs to:
1
2
3
4
5
projects/<project_slug>/logs/<env_tag>/<YYYYMMDD_HHMMSS>/
├─ checkpoints/
├─ videos/
├─ monitor.csv
└─ tb/
TensorBoard:
1
tensorboard --logdir projects/<project_slug>/logs
Custom MuJoCo XML Assets
Store per-project XML and related files under:
1
projects/<project_slug>/source/assets/
Recommended: resolve XML paths relative to the env file (via __file__) rather than relying on the current working directory.
Git / Version Control Notes
Typical .gitignore entries for this workspace:
projects/**/logs/projects/**/__pycache__/projects/**/.venv/**/*.zip(model checkpoints)**/*.pkl(VecNormalize stats)**/*.mp4(videos).DS_Store
Recommended workflow:
- Keep this repo (
mj_ws) focused on tools/templates. Treat each generated project as either:
- its own repo, or
- a local experiment folder ignored by git.
Troubleshooting
“Environment doesn’t exist”
- Ensure
import envsis executed beforegym.make(ENV_ID). - With
SubprocVecEnv(start_method="spawn"), env registration must happen in every worker process. This workspace template importsenvsinside the worker initializer for that reason.
“Broken editable install”
If you removed a project folder but it still appears installed:
1
pip uninstall <project_package_name>