Publish three synthetic G1 sidestep clips and replay tools
Browse filesFiles changed (12)
- README.mdAdded+95
- UNITREE-LICENSE.txtAdded+27
- clips.csvAdded+4
- clips/sidestep_left_001.npzAdded+3
- clips/sidestep_left_002_wide.npzAdded+3
- clips/sidestep_left_003_fast.npzAdded+3
- generate.pyAdded+261
- inspect_clips.pyAdded+113
- inspection.jsonAdded+142
- preview.gifAdded
- replay.pyAdded+65
- settings.jsonAdded+24
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495---pretty_name: VECTOR Unitree G1 Synthetic Sidesteptags:- robotics- timeseries- motion-trajectory- unitree-g1configs:- config_name: clips default: true data_files: - split: train path: clips.csv---
# VECTOR Unitree G1 Synthetic Sidestep
Three synthetic humanoid motion clips with a replay, generation settings, and per-clip kinematic checks. Each clip represents the same 29-joint Unitree G1 taking one left side step while the right foot is planned to remain planted. The variants change step width or left-foot swing time.
This is the distribution home for VECTOR motion datasets. It packages the files previously maintained in a separate GitHub repository. The source files, checks, and model notice are preserved here from migration snapshot `50159f0fcd88c3c3a7bf5a4faddc08dcdfe2dfe1`. This repository deliberately does not assign a license to the synthetic trajectories because the original distribution did not state one. The Unitree model notice is included in [UNITREE-LICENSE.txt](UNITREE-LICENSE.txt).

## Dataset contents
The `clips` viewer configuration opens [clips.csv](clips.csv), an index for the three downloadable `.npz` trajectories. The `file` values in that table are repository-relative paths.
| Clip | Step width | Left-foot swing time | Duration | Frames at 50 Hz || --- | ---: | ---: | ---: | ---: || [Baseline](clips/sidestep_left_001.npz) | 12 cm | 0.80 s | 2.20 s | 111 || [Wider step](clips/sidestep_left_002_wide.npz) | 18 cm | 1.20 s | 2.60 s | 131 || [Faster step](clips/sidestep_left_003_fast.npz) | 12 cm | 0.60 s | 2.00 s | 101 |
- [clips/](clips/) contains the three NumPy NPZ trajectories.- [clips.csv](clips.csv) records dimensions, sampling rate, duration, joint-limit result, and SHA-256 for every clip.- [inspection.json](inspection.json) holds the per-clip replay measurements.- [settings.json](settings.json), [generate.py](generate.py), [replay.py](replay.py), and [inspect_clips.py](inspect_clips.py) reproduce and inspect the trajectory workflow.- [preview.gif](preview.gif) is the baseline kinematic replay.- [UNITREE-LICENSE.txt](UNITREE-LICENSE.txt) is the model-license notice used for that replay.
## Schema
Each NPZ file contains `time_s`, `joint_names`, and `joint_pos_rad`. It also contains world-frame pelvis and torso positions and orientations in `pelvis_pos_m`, `torso_pos_m`, `pelvis_quat_wxyz`, and `torso_quat_wxyz`.
The coordinate axes are forward `+X`, left `+Y`, and up `+Z`. Positions use metres, joint positions use radians, and quaternions use WXYZ order. `foot_contact_planned` has left and right columns and represents the planned contact state used when generating these synthetic trajectories.
```pythonimport numpy as np
with np.load("clips/sidestep_left_001.npz", allow_pickle=False) as clip: print(clip["joint_pos_rad"].shape) # (111, 29) print(clip["foot_contact_planned"].sum(axis=0)) # [72, 111] frames```
## Kinematic checks
VECTOR generated the trajectories using inverse kinematics and replayed the saved poses in MuJoCo 4.0.1. Across all 343 frames, every recorded joint value remained within its G1 model limit. In the reference geometry, the right foot remains within the planned stance and the left foot clears the floor during its swing.
`foot_contact_planned` is a generation label. Measured contact forces, dynamic balance, learning performance, and physical-robot trials are not included. At a 1 mm geometric proximity threshold, a foot in swing can still be near the floor. The three clips have 8, 14, and 6 such left-foot swing frames respectively. See [inspection.json](inspection.json) for the exact frame records and [inspect_clips.py](inspect_clips.py) for the calculation.
## Reproduce the replay and checks
The original process used Python 3.12, MuJoCo 4.0.1, NumPy 2.5.5, GLFW 2.11.0, and the Unitree G1 model from MuJoCo Menagerie at commit `eea4c7431b63da8278b0ff31638e0b0e941cec0e`. A desktop with an OpenGL window is required for replay.
```shruntime=$(mktemp -d)python3.12 -m venv "$runtime/venv". "$runtime/venv/bin/activate"python -m pip install "mujoco==4.0.1" "numpy==2.5.5" "glfw==2.11.0"
git clone --filter=blob:none --sparse --no-checkout https://github.com/google-deepmind/mujoco_menagerie.git "$runtime/menagerie"git -C "$runtime/menagerie" sparse-checkout set unitree_g1git -C "$runtime/menagerie" checkout --detach eea4c7431b63da8278b0ff31638e0b0e941cec0escene="$runtime/menagerie/unitree_g1/scene.xml"
python replay.py clips/sidestep_left_001.npz --scene "$scene"python inspect_clips.py --scene "$scene"```
To generate the three trajectories again in a separate folder:
```shpython generate.py --scene "$scene" --output "$runtime/regenerated"```
## Citation
```bibtex@dataset{vector_g1_synthetic_sidestep, title = {VECTOR Unitree G1 Synthetic Sidestep}, author = {Lee, Seokhee}, year = {2026}, note = {Three synthetic G1 reference trajectories with kinematic inspection records}}```123456789101112131415161718192021222324252627Copyright (c) 2016-2023 HangZhou YuShu TECHNOLOGY CO.,LTD. ("Unitree Robotics")All rights reserved.
Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AREDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLEFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ORSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVERCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USEOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.1234file,step_width_m,swing_duration_s,sample_rate_hz,frames,duration_s,joint_limit_violations,sha256clips/sidestep_left_001.npz,0.12,0.8,50,111,2.2,0,c34ad0becfa90406856aa5712502e8774f3f83a18b8d49909f3aa250fbb6b1f2clips/sidestep_left_002_wide.npz,0.18,1.2,50,131,2.6,0,0bffffe448a23ef658ffb9b54611cbd5820f105ec226d956d9fb896d77608dd7clips/sidestep_left_003_fast.npz,0.12,0.6,50,101,2.0,0,f9d943981afc6027ce31899095ecaa115b2390aa31b40beb223325503ac83cb0123version https://git-lfs.github.com/spec/v1oid sha256:c34ad0becfa90406856aa5712502e8774f3f83a18b8d49909f3aa250fbb6b1f2size 44396123version https://git-lfs.github.com/spec/v1oid sha256:0bffffe448a23ef658ffb9b54611cbd5820f105ec226d956d9fb896d77608dd7size 51476123version https://git-lfs.github.com/spec/v1oid sha256:f9d943981afc6027ce31899095ecaa115b2390aa31b40beb223325503ac83cb0size 40856123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261#!/usr/bin/env python3"""Generate reproducible, kinematic Unitree G1 side-step reference clips.
The output represents an inverse-kinematics reference trajectory. It is usefulfor exercising the dataset schema and replay pipeline. It is not a dynamicsimulation, a controller, or evidence that the motion transfers to hardware."""
from __future__ import annotations
import argparseimport jsonfrom pathlib import Path
import mujocoimport numpy as np
FPS = 50LEFT_FOOT = "left_foot"RIGHT_FOOT = "right_foot"PELVIS = "pelvis"TORSO = "torso_link"LEFT_LEG = ( "left_hip_pitch_joint", "left_hip_roll_joint", "left_hip_yaw_joint", "left_knee_joint", "left_ankle_pitch_joint", "left_ankle_roll_joint",)RIGHT_LEG = ( "right_hip_pitch_joint", "right_hip_roll_joint", "right_hip_yaw_joint", "right_knee_joint", "right_ankle_pitch_joint", "right_ankle_roll_joint",)
def smoothstep(progress: float) -> float: """Return a position profile with zero velocity at both endpoints.""" clamped = np.clip(progress, 0.0, 1.0) return clamped * clamped * (3.0 - 2.0 * clamped)
def phase(time_s: float, start_s: float, duration_s: float) -> float: return smoothstep((time_s - start_s) / duration_s)
def lowest_sole_point(model: mujoco.MjModel, data: mujoco.MjData) -> float: """Return the lowest collision-sphere point of either G1 foot in world Z.""" lowest = np.inf for site_name in (LEFT_FOOT, RIGHT_FOOT): site_id = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_SITE, site_name) foot_body_id = model.site_bodyid[site_id] for geom_id, body_id in enumerate(model.geom_bodyid): if body_id != foot_body_id: continue if model.geom_type[geom_id] != mujoco.mjtGeom.mjGEOM_SPHERE: continue lowest = min(lowest, data.geom_xpos[geom_id, 2] - model.geom_size[geom_id, 0]) if not np.isfinite(lowest): raise ValueError("could not find the G1 foot collision spheres") return lowest
def joint_layout(model: mujoco.MjModel) -> tuple[list[str], np.ndarray, np.ndarray]: names = [] qpos_addresses = [] dof_addresses = [] for joint_id in range(model.njnt): if model.jnt_type[joint_id] == mujoco.mjtJoint.mjJNT_FREE: continue names.append(mujoco.mj_id2name(model, mujoco.mjtObj.mjOBJ_JOINT, joint_id)) qpos_addresses.append(model.jnt_qposadr[joint_id]) dof_addresses.append(model.jnt_dofadr[joint_id]) return names, np.asarray(qpos_addresses), np.asarray(dof_addresses)
def site_position(data: mujoco.MjData, site_id: int) -> np.ndarray: return data.site_xpos[site_id].copy()
def site_rotation(data: mujoco.MjData, site_id: int) -> np.ndarray: return data.site_xmat[site_id].reshape(3, 3).copy()
def orientation_error(current: np.ndarray, target: np.ndarray) -> np.ndarray: """Small-angle rotation from current orientation to target orientation.""" relative = target @ current.T return 0.5 * np.array(( relative[2, 1] - relative[1, 2], relative[0, 2] - relative[2, 0], relative[1, 0] - relative[0, 1], ))
def solve_frame( model: mujoco.MjModel, data: mujoco.MjData, leg_limits: np.ndarray, variable_qpos: np.ndarray, variable_dofs: np.ndarray, foot_site_ids: tuple[int, int], foot_targets: tuple[np.ndarray, np.ndarray], foot_rotations: tuple[np.ndarray, np.ndarray], pelvis_target_y: float,) -> None: """Hold both foot sites level while shifting the free-base pelvis laterally.""" position_jacobian = np.empty((3, model.nv)) rotation_jacobian = np.empty((3, model.nv)) regularization = 5e-5
# The previous frame is a warm start. A modest iteration limit retains a # smooth sequence and makes a solver failure visible to the caller. for _ in range(120): mujoco.mj_forward(model, data) errors = [] jacobians = [] for site_id, target_pos, target_rot in zip( foot_site_ids, foot_targets, foot_rotations, strict=True ): mujoco.mj_jacSite(model, data, position_jacobian, rotation_jacobian, site_id) errors.extend((target_pos - site_position(data, site_id)) * 12.0) errors.extend(orientation_error(site_rotation(data, site_id), target_rot) * 2.0) jacobians.append(position_jacobian[:, variable_dofs] * 12.0) jacobians.append(rotation_jacobian[:, variable_dofs] * 2.0)
# The pelvis target creates a visible, intentional weight shift while # the foot constraints determine the compensating leg configuration. errors.append((pelvis_target_y - data.qpos[1]) * 1.5) pelvis_row = np.zeros((1, len(variable_dofs))) pelvis_row[0, 0] = 1.5 jacobians.append(pelvis_row) jacobian = np.concatenate(jacobians) error = np.asarray(errors) if np.max(np.abs(error)) < 1e-6: return
delta = np.linalg.solve( jacobian.T @ jacobian + regularization * np.eye(len(variable_dofs)), jacobian.T @ error, ) data.qpos[variable_qpos] += np.clip(delta, -0.03, 0.03)
leg_qpos = variable_qpos[2:] data.qpos[leg_qpos] = np.clip(data.qpos[leg_qpos], leg_limits[:, 0], leg_limits[:, 1])
raise RuntimeError( f"inverse kinematics did not converge for one frame, max residual={np.max(np.abs(error)):.6f}" )
def trajectory_times(settings: dict, clip: dict) -> np.ndarray: motion = settings["motion"] duration = ( motion["pre_hold_s"] + motion["weight_shift_s"] + clip["swing_duration_s"] + motion["post_shift_s"] + motion["final_hold_s"] ) return np.arange(round(duration * settings["fps"]) + 1) / settings["fps"]
def generate_clip(model: mujoco.MjModel, settings: dict, clip: dict) -> dict[str, np.ndarray]: data = mujoco.MjData(model) mujoco.mj_resetDataKeyframe(model, data, 0) motion = settings["motion"] for side_name in ("left", "right"): for joint_name, value in motion["initial_leg_angles_rad"].items(): joint = model.joint(f"{side_name}_{joint_name}_joint") data.qpos[joint.qposadr[0]] = value mujoco.mj_forward(model, data) # Align the crouched starting pose to the plane using the collision sphere bottoms. data.qpos[2] -= lowest_sole_point(model, data) mujoco.mj_forward(model, data) initial_qpos = data.qpos.copy() names, qpos_addresses, dof_addresses = joint_layout(model) leg_names = LEFT_LEG + RIGHT_LEG leg_limits = np.array([model.joint(name).range for name in leg_names]) leg_indices = np.asarray([names.index(name) for name in leg_names]) variable_qpos = np.concatenate((np.array((1, 2)), qpos_addresses[leg_indices])) variable_dofs = np.concatenate((np.array((1, 2)), dof_addresses[leg_indices])) left_id = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_SITE, LEFT_FOOT) right_id = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_SITE, RIGHT_FOOT) initial_left = site_position(data, left_id) initial_right = site_position(data, right_id) rotations = (site_rotation(data, left_id), site_rotation(data, right_id)) times = trajectory_times(settings, clip) frames = len(times) joint_pos = np.empty((frames, len(names))) pelvis_pos = np.empty((frames, 3)) pelvis_quat = np.empty((frames, 4)) torso_pos = np.empty((frames, 3)) torso_quat = np.empty((frames, 4)) contact = np.zeros((frames, 2), dtype=bool) pelvis_id = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_BODY, PELVIS) torso_id = mujoco.mj_name2id(model, mujoco.mjtObj.mjOBJ_BODY, TORSO) shift_end = motion["pre_hold_s"] + motion["weight_shift_s"] swing_end = shift_end + clip["swing_duration_s"] target_left_y = initial_left[1] + clip["step_width_m"] # Shift onto the right side, follow the swinging foot, then settle between the feet. support_y = initial_right[1] + motion["support_offset_y_m"] landing_y = support_y + clip["step_width_m"] * motion["pelvis_travel_fraction"] final_y = (target_left_y + initial_right[1]) / 2.0
for frame, time_s in enumerate(times): swing = phase(time_s, shift_end, clip["swing_duration_s"]) lift = np.sin(np.pi * swing) ** 2 left_target = initial_left.copy() left_target[1] += clip["step_width_m"] * swing left_target[2] += motion["clearance_m"] * lift if time_s < shift_end: pelvis_y = initial_qpos[1] + (support_y - initial_qpos[1]) * phase( time_s, motion["pre_hold_s"], motion["weight_shift_s"] ) elif time_s < swing_end: pelvis_y = support_y + (landing_y - support_y) * swing else: pelvis_y = landing_y + (final_y - landing_y) * phase( time_s, swing_end, motion["post_shift_s"] ) try: solve_frame( model, data, leg_limits, variable_qpos, variable_dofs, (left_id, right_id), (left_target, initial_right), rotations, pelvis_y, ) except RuntimeError as error: raise RuntimeError(f"{clip['id']} at {time_s:.2f}s: {error}") from error mujoco.mj_forward(model, data) joint_pos[frame] = data.qpos[qpos_addresses] pelvis_pos[frame] = data.xpos[pelvis_id] pelvis_quat[frame] = data.xquat[pelvis_id] torso_pos[frame] = data.xpos[torso_id] torso_quat[frame] = data.xquat[torso_id] contact[frame] = (left_target[2] <= initial_left[2] + 1e-9, True)
return { "time_s": times, "joint_names": np.asarray(names), "joint_pos_rad": joint_pos, "pelvis_pos_m": pelvis_pos, "pelvis_quat_wxyz": pelvis_quat, "torso_pos_m": torso_pos, "torso_quat_wxyz": torso_quat, "foot_contact_planned": contact, }
def main() -> None: parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--scene", type=Path, required=True, help="Pinned Menagerie scene.xml") parser.add_argument("--output", type=Path, required=True, help="Directory for generated NPZ clips") parser.add_argument( "--settings", type=Path, default=Path(__file__).with_name("settings.json"), help="Generator settings JSON", ) args = parser.parse_args() settings = json.loads(args.settings.read_text()) if settings["fps"] != FPS: raise ValueError(f"This generator writes {FPS} Hz clips only") model = mujoco.MjModel.from_xml_path(str(args.scene)) args.output.mkdir(parents=True, exist_ok=True) for clip in settings["clips"]: arrays = generate_clip(model, settings, clip) np.savez(args.output / f"{clip['id']}.npz", **arrays)
if __name__ == "__main__": main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113"""Measure joint margins, foot clearance and stance drift for saved G1 clips."""
import argparseimport hashlibimport jsonfrom pathlib import Path
import mujocoimport numpy as np
# A geometric proximity band for this report, expressed in millimetres.FLOOR_BAND_MM = 1.0
def foot_metrics(points_mm, planned): """points_mm contains the bottoms of four sole spheres, in world coordinates.""" heights = points_mm[:, :, 2] lowest = heights.min(axis=1) near_floor = lowest <= FLOOR_BAND_MM # Each touchdown starts a new reference for all four points on that foot. edges = np.flatnonzero(np.diff(np.r_[False, planned, False])) max_drift = 0.0 for begin, end in edges.reshape(-1, 2): displacement = points_mm[begin:end, :, :2] - points_mm[begin, :, :2] max_drift = max(max_drift, float(np.linalg.norm(displacement, axis=-1).max())) return { "planned_stance_frames": int(planned.sum()), "planned_stance_runs": len(edges) // 2, "max_stance_drift_mm": max_drift, "max_stance_abs_height_mm": float(np.abs(heights[planned]).max()) if planned.any() else None, "max_floor_penetration_mm": max(0.0, -float(lowest.min())), "peak_clearance_mm": float(lowest.max()), "stance_above_band_frames": np.flatnonzero(planned & ~near_floor).tolist(), "swing_in_band_frames": np.flatnonzero(~planned & near_floor).tolist(), "swing_at_or_below_floor_frames": np.flatnonzero(~planned & (lowest <= 0)).tolist(), }
def inspect(model, clip_path): with np.load(clip_path, allow_pickle=False) as clip: times = clip["time_s"] names = clip["joint_names"].tolist() angles = clip["joint_pos_rad"] pelvis = clip["pelvis_pos_m"] quat = clip["pelvis_quat_wxyz"] planned = clip["foot_contact_planned"] frames = len(times) if frames < 2 or times[0] != 0 or not np.allclose(np.diff(times), 0.02): raise ValueError(f"{clip_path}: expected a 50 Hz timeline starting at zero") joints = np.array([model.joint(name).id for name in names]) hinges = np.flatnonzero(model.jnt_type == mujoco.mjtJoint.mjJNT_HINGE) if len(joints) != 29 or not np.array_equal(np.sort(joints), hinges): raise ValueError(f"{clip_path}: expected all 29 G1 hinges exactly once") if angles.shape != (frames, 29) or pelvis.shape != (frames, 3) or quat.shape != (frames, 4): raise ValueError(f"{clip_path}: unexpected pose dimensions") if not all(np.isfinite(field).all() for field in (angles, pelvis, quat)): raise ValueError(f"{clip_path}: non-finite pose") if planned.dtype != bool or planned.shape != (frames, 2): raise ValueError(f"{clip_path}: expected left/right boolean contact labels")
low, high = model.jnt_range[joints].T margins = np.minimum(angles - low, high - angles) closest_frame, closest_joint = np.unravel_index(margins.argmin(), margins.shape) joint_check = { "outside_limit_values": int((margins < 0).sum()), "min_margin_rad": float(margins.min()), "closest_joint": names[closest_joint], "closest_frame": int(closest_frame), }
sides = ("left", "right") soles = [] for side in sides: body = model.body(f"{side}_ankle_roll_link").id geoms = np.flatnonzero((model.geom_bodyid == body) & (model.geom_type == mujoco.mjtGeom.mjGEOM_SPHERE)) if len(geoms) != 4: raise ValueError(f"{side} foot must have four sole spheres") soles.append(geoms) soles = np.array(soles) data = mujoco.MjData(model) points = np.empty((frames, 2, 4, 3)) root = model.joint("floating_base_joint").qposadr[0] addresses = model.jnt_qposadr[joints] for frame in range(frames): data.qpos[root : root + 3] = pelvis[frame] data.qpos[root + 3 : root + 7] = quat[frame] data.qpos[addresses] = angles[frame] mujoco.mj_forward(model, data) points[frame] = data.geom_xpos[soles] points[frame, :, :, 2] -= model.geom_size[soles, 0] feet = {side: foot_metrics(points[:, i] * 1000, planned[:, i]) for i, side in enumerate(sides)} return { "file": clip_path.name, "sha256": hashlib.sha256(clip_path.read_bytes()).hexdigest(), "frames": frames, "joints": joint_check, "feet": feet, }
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--scene", type=Path, required=True, help="Pinned Menagerie unitree_g1/scene.xml") args = parser.parse_args() folder = Path(__file__).resolve().parent settings = json.loads((folder / "settings.json").read_text()) model = mujoco.MjModel.from_xml_path(str(args.scene)) clips = [inspect(model, folder / "clips" / (item["id"] + ".npz")) for item in settings["clips"]] print(json.dumps({"mujoco": mujoco.__version__, "floor_band_mm": FLOOR_BAND_MM, "clips": clips}, indent=2))
if __name__ == "__main__": main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142{ "mujoco": "4.0.1", "floor_band_mm": 1.0, "clips": [ { "file": "sidestep_left_001.npz", "sha256": "c34ad0becfa90406856aa5712502e8774f3f83a18b8d49909f3aa250fbb6b1f2", "frames": 111, "joints": { "outside_limit_values": 0, "min_margin_rad": 0.07217552339741887, "closest_joint": "left_ankle_roll_joint", "closest_frame": 56 }, "feet": { "left": { "planned_stance_frames": 72, "planned_stance_runs": 2, "max_stance_drift_mm": 2.0081560450441607e-07, "max_stance_abs_height_mm": 8.894924042116004e-07, "max_floor_penetration_mm": 7.900112074937793e-08, "peak_clearance_mm": 70.00000011486277, "stance_above_band_frames": [], "swing_in_band_frames": [ 36, 37, 38, 39, 71, 72, 73, 74 ], "swing_at_or_below_floor_frames": [] }, "right": { "planned_stance_frames": 111, "planned_stance_runs": 1, "max_stance_drift_mm": 1.3308644394995443e-05, "max_stance_abs_height_mm": 3.7112290099568235e-05, "max_floor_penetration_mm": 7.845584069562928e-07, "peak_clearance_mm": 3.3223870204469874e-05, "stance_above_band_frames": [], "swing_in_band_frames": [], "swing_at_or_below_floor_frames": [] } } }, { "file": "sidestep_left_002_wide.npz", "sha256": "0bffffe448a23ef658ffb9b54611cbd5820f105ec226d956d9fb896d77608dd7", "frames": 131, "joints": { "outside_limit_values": 0, "min_margin_rad": 0.06647430318707331, "closest_joint": "left_ankle_roll_joint", "closest_frame": 68 }, "feet": { "left": { "planned_stance_frames": 72, "planned_stance_runs": 2, "max_stance_drift_mm": 2.1554815863741615e-07, "max_stance_abs_height_mm": 8.894924042116004e-07, "max_floor_penetration_mm": 1.1621199749040079e-07, "peak_clearance_mm": 70.00000014817034, "stance_above_band_frames": [], "swing_in_band_frames": [ 36, 37, 38, 39, 40, 41, 42, 88, 89, 90, 91, 92, 93, 94 ], "swing_at_or_below_floor_frames": [] }, "right": { "planned_stance_frames": 131, "planned_stance_runs": 1, "max_stance_drift_mm": 5.826346123723882e-06, "max_stance_abs_height_mm": 1.6498895771301092e-05, "max_floor_penetration_mm": 6.402840922389852e-07, "peak_clearance_mm": 1.4644754430838403e-05, "stance_above_band_frames": [], "swing_in_band_frames": [], "swing_at_or_below_floor_frames": [] } } }, { "file": "sidestep_left_003_fast.npz", "sha256": "f9d943981afc6027ce31899095ecaa115b2390aa31b40beb223325503ac83cb0", "frames": 101, "joints": { "outside_limit_values": 0, "min_margin_rad": 0.07227313454116735, "closest_joint": "left_ankle_roll_joint", "closest_frame": 51 }, "feet": { "left": { "planned_stance_frames": 72, "planned_stance_runs": 2, "max_stance_drift_mm": 1.3334023616862804e-07, "max_stance_abs_height_mm": 8.894924042116004e-07, "max_floor_penetration_mm": 7.770161510739504e-08, "peak_clearance_mm": 70.0000006255453, "stance_above_band_frames": [], "swing_in_band_frames": [ 36, 37, 38, 62, 63, 64 ], "swing_at_or_below_floor_frames": [] }, "right": { "planned_stance_frames": 101, "planned_stance_runs": 1, "max_stance_drift_mm": 2.6619246393423334e-06, "max_stance_abs_height_mm": 1.2674277357661856e-05, "max_floor_penetration_mm": 9.707865683203365e-07, "peak_clearance_mm": 1.1992847594351208e-05, "stance_above_band_frames": [], "swing_in_band_frames": [], "swing_at_or_below_floor_frames": [] } } } ]}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465"""Play one saved G1 clip in the MuJoCo viewer at its recorded timestamps."""
import argparseimport timefrom pathlib import Path
import glfwimport mujocoimport numpy as np
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("clip", type=Path, help="G1 sidestep NPZ file") parser.add_argument("--scene", required=True, type=Path, help="Menagerie unitree_g1/scene.xml") args = parser.parse_args() model = mujoco.MjModel.from_xml_path(str(args.scene)) data = mujoco.MjData(model)
with np.load(args.clip, allow_pickle=False) as clip: times = clip["time_s"] positions = clip["pelvis_pos_m"] orientations = clip["pelvis_quat_wxyz"] angles = clip["joint_pos_rad"] joint_addresses = [model.joint(str(name)).qposadr[0] for name in clip["joint_names"]] root = model.joint("floating_base_joint").qposadr[0]
if not glfw.init(): raise RuntimeError("Open replay.py in a desktop session with an OpenGL display.") try: window = glfw.create_window(800, 600, args.clip.stem, None, None) if not window: raise RuntimeError("Could not open the playback window.") glfw.make_context_current(window) context = mujoco.MjrContext(model, mujoco.mjtFontScale.mjFONTSCALE_100) scene = mujoco.MjvScene(model, maxgeom=1000) options = mujoco.MjvOption() camera = mujoco.MjvCamera() camera.lookat[:] = [0.02, 0.08, 0.66] camera.distance, camera.azimuth, camera.elevation = 2.35, 2, -18 start = time.monotonic() shown = 0 for timestamp, pos, quat, joints in zip(times, positions, orientations, angles, strict=True): glfw.poll_events() if glfw.window_should_close(window): break data.time = timestamp data.qpos[root : root + 3] = pos data.qpos[root + 3 : root + 7] = quat data.qpos[joint_addresses] = joints mujoco.mj_forward(model, data) mujoco.mjv_updateScene(model, data, options, None, camera, mujoco.mjtCatBit.mjCAT_ALL, scene) width, height = glfw.get_framebuffer_size(window) mujoco.mjr_render(mujoco.MjrRect(0, 0, width, height), scene, context) time.sleep(max(0.0, start + timestamp - time.monotonic())) glfw.swap_buffers(window) shown += 1 context.free() finally: glfw.terminate() print(f"{args.clip.name}: {shown}/{len(times)} frames")
if __name__ == "__main__": main()123456789101112131415161718192021222324{ "format_version": 1, "model": { "source": "MuJoCo Menagerie Unitree G1", "commit": "eea4c7431b63da8278b0ff31638e0b0e941cec0e", "scene": "unitree_g1/scene.xml" }, "fps": 50, "motion": { "initial_leg_angles_rad": {"hip_pitch": -0.23, "knee": 0.46, "ankle_pitch": -0.23}, "support_offset_y_m": 0.016, "pelvis_travel_fraction": 0.90, "clearance_m": 0.07, "pre_hold_s": 0.4, "weight_shift_s": 0.3, "post_shift_s": 0.3, "final_hold_s": 0.4 }, "clips": [ {"id": "sidestep_left_001", "step_width_m": 0.12, "swing_duration_s": 0.8}, {"id": "sidestep_left_002_wide", "step_width_m": 0.18, "swing_duration_s": 1.2}, {"id": "sidestep_left_003_fast", "step_width_m": 0.12, "swing_duration_s": 0.6} ]}README.mdAdded+95
UNITREE-LICENSE.txtAdded+27
clips.csvAdded+4
clips/sidestep_left_001.npzAdded+3
clips/sidestep_left_002_wide.npzAdded+3
clips/sidestep_left_003_fast.npzAdded+3
generate.pyAdded+261
inspect_clips.pyAdded+113
inspection.jsonAdded+142
preview.gifAdded

Large File Pointer Details
- SHA256: 0b4045ba39270fbf6f1a950ced6d98d264d7f72908ad049105f101e6569cb3f0
- Pointer size: 132 Bytes
- Size of remote file: 4.25 MB
replay.pyAdded+65
settings.jsonAdded+24