mjswan demo assets
What the mjswan demo loads. These files live here rather than in the repository, so a clone stays small and a build fetches what it needs.
The scenes mjlab supplies as tasks โ G1, Go1, Yam, cartpole โ are deliberately not
under scenes/: add_scene_mjlab assembles those from the task itself. What is here is
the one scene mjlab has no task for, and the trained policies, which no package ships.
Usage
import re
import mjswan
from mjswan.source import hf
REPO = "ttktjmt/mjswan"
builder = mjswan.Builder()
project = builder.add_project(name="Showcase")
scene = project.add_scene_hf(REPO, "scenes/unitree_g1/scene.xml", control_dt=0.02)
scene.add_policy_hf(
REPO, filename=["policies/locomotion.onnx", "policies/balance.onnx"]
)
# Several splats can share one scene; the viewer shows a selector to switch between
# them, and only the selected one is fetched.
scene.add_splat_hf(REPO, "splats/street.spz", name="Street",
scale=3.275, z_offset=0.708, yaw=40)
scene.add_splat_hf(REPO, "splats/cafe.spz", name="Cafe",
scale=3.275, z_offset=0.708)
# An mjlab task's checkpoints, ordered by training step. `list_repo_onnx` sorts as
# strings, which would put `model_1000` before `model_500`.
files = hf.list_repo_onnx(REPO)
prefix = "checkpoints/mjlab-velocity-flat-unitree-g1/"
names = sorted(
(n for n in files if n.startswith(prefix)),
key=lambda n: int(re.search(r"_(\d+)\.onnx$", n).group(1)),
)
builder.build().launch()
Needs pip install mjswan[hf]. Nothing here requires mjlab or torch to load โ those
are needed only to build a scene from an mjlab task.
Contents
| Path | What it is |
|---|---|
scenes/unitree_g1/ |
The 29-DoF Unitree G1, as MJCF plus the meshes it resolves. The two policies under policies/ were trained against this XML |
policies/*.onnx |
Locomotion and standing balance for the G1. The matching .json is a sidecar carrying PD gains and the rest of the policy config |
splats/*.spz |
Gaussian Splat captures used as backgrounds. street and cafe go on the same scene, switchable in the viewer |
checkpoints/<task-id>/model_<step>.onnx |
Training checkpoints for an mjlab task. <task-id> is the mjlab task name lowercased; <step> is the training step |
motions/*.npz |
Reference motions for the tracking task |
Every ONNX under checkpoints/ carries mjlab's metadata_props except the two cartpole
tasks, whose environment has no robot entity and no joint_pos action term for mjlab's
exporter to describe. Where the metadata is present, add_policy_hf reads the joint names
and the rest pose from the file instead of asking for them again โ and only when your
scene's own model presents the same joints in actuator order, since pairing lists that
disagree would misdrive every actuator with nothing at playback to say so.
Licensing
This repository mixes licenses.
policies/,checkpoints/,motions/,splats/โ Apache-2.0, mjswan Developers.scenes/unitree_g1/โ see theLICENSEbeside the model. The G1 is Unitree Robotics' and comes from mujoco_menagerie.
A LICENSE under scenes/ travels with the model: mjswan detects it when the scene is
added and copies it into the build output, so a deployed app carries its attributions.