Instructions to use mizuchi-lab/unitree-g1-mujoco with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LeRobot
How to use mizuchi-lab/unitree-g1-mujoco with LeRobot:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Commit ·
aba4c8d
1
Parent(s): c6cc337
feat: thumb pose map tool and thumb open/closed poses for the side grasp
Browse filesFiles changed (2)
- tools/grasp_diag.py+4-3
- tools/thumb_map.pyAdded+80
25 unmodified lines2627282930313233208 unmodified lines24224324424524624724825 unmodified linesPELVIS_Z = 0.74ARM_GAINS = {"arm": (300.0, 6.0), "wrist": (40.0, 1.5)}HAND_JOINTS = [f"right_hand_motor{i}_joint" for i in range(1, 9)]OPEN_DEG = np.array([-35.0, 35.0] * 4)CLOSED_DEG = np.array([60.0, -60.0] * 3 + [75.0, -75.0])@dataclasses.dataclass208 unmodified linesmodel, data = env.mj_model, env.mj_dataik_level, ik_lift = _ik(p.rotation_weight), _ik(1.0)data.ctrl[self.hand_ids] = np.radians(p.open_deg)data.ctrl[[model.actuator(f"left_hand_motor{i}_joint").id for i in range(11, 19)]] = np.radians(OPEN_DEG)dt = env.sim_dtcylinder = data.qpos[self.cyl_adr : self.cyl_adr + 3].copy()grasp = cylinder - p.grasp_offset25 unmodified lines262728293031323334208 unmodified lines24324424524624724824925 unmodified linesPELVIS_Z = 0.74ARM_GAINS = {"arm": (300.0, 6.0), "wrist": (40.0, 1.5)}HAND_JOINTS = [f"right_hand_motor{i}_joint" for i in range(1, 9)]# Thumb from tools/thumb_map.py: open is up above the cylinder, closed presses its near face (hardware must confirm).OPEN_DEG = np.array([-35.0, 35.0] * 3 + [-80.0, -70.0])CLOSED_DEG = np.array([60.0, -60.0] * 3 + [40.0, -70.0])@dataclasses.dataclass208 unmodified linesmodel, data = env.mj_model, env.mj_dataik_level, ik_lift = _ik(p.rotation_weight), _ik(1.0)data.ctrl[self.hand_ids] = np.radians(p.open_deg)data.ctrl[[model.actuator(f"left_hand_motor{i}_joint").id for i in range(11, 19)]] = np.radians([-35.0, 35.0] * 4)dt = env.sim_dtcylinder = data.qpos[self.cyl_adr : self.cyl_adr + 3].copy()grasp = cylinder - p.grasp_offset
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980"""Thumb pose map: sweep the right AmazingHand thumb servos (motor7, motor8) in free air at the grasp pose andreport the thumb tip in the TCP frame (x along the forearm, y palm normal, z up). Heatmaps go to --png.Run: MUJOCO_GL=egl python tools/thumb_map.py [--png out.png]"""
import argparseimport osimport sysfrom pathlib import Path
os.environ.setdefault("MUJOCO_GL", "egl")ROOT = Path(__file__).resolve().parents[1]sys.path.insert(0, str(ROOT / "tools"))sys.path.insert(0, str(ROOT / "tests"))
import numpy as np
from grasp_diag import Grasp, GraspParams, _ik, _pose
def thumb_map(step=10, settle_s=0.4): params = GraspParams() run = Grasp(params) model, data = run.env.mj_model, run.env.mj_data cylinder = data.qpos[run.cyl_adr : run.cyl_adr + 3].copy() data.qpos[run.cyl_adr : run.cyl_adr + 3] = [1.5, 1.0, 0.9] ik = _ik(params.rotation_weight) data.ctrl[run.hand_ids] = np.radians(params.open_deg) grasp = cylinder - params.grasp_offset stage = grasp - params.standoff * np.asarray(params.approach) + [-0.05, -0.12, 0.0] ik.reset(np.zeros(ik.nq)) for _ in range(8): solution = ik.solve(run.left_target, _pose(stage - run.pelvis, run.rotation)) run.arm.update(zip(ik.joint_names, solution.q)) for name, value in run.arm.items(): data.qpos[model.jnt_qposadr[model.joint(name).id]] = value half = int(0.5 / run.env.sim_dt) run.stage = "settle" run.step(half) run.move(ik, stage, grasp, 1.0, warm=solution.q) run.step(half) rotation, origin = data.site_xmat[run.tcp].reshape(3, 3), data.site_xpos[run.tcp].copy() tip = model.site("right_hand_tip4").id angles = list(range(-90, 91, step)) table = {} for a in angles: for b in angles: command = np.radians(params.open_deg).copy() command[6], command[7] = np.radians(a), np.radians(b) data.ctrl[run.hand_ids] = command run.step(int(settle_s / run.env.sim_dt)) table[(a, b)] = rotation.T @ (data.site_xpos[tip] - origin) return angles, table
def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--png") args = parser.parse_args() angles, table = thumb_map() for a, b in ((-80, -70), (40, -70)): print(f"m7={a} m8={b} tip", table[(a, b)].round(3)) if args.png: import matplotlib
matplotlib.use("Agg") import matplotlib.pyplot as plt
figure, axes = plt.subplots(1, 3, figsize=(15, 4.5)) for index, (axis, label) in enumerate(zip(axes, "xyz")): grid = np.array([[table[(a, b)][index] * 100 for b in angles] for a in angles]) image = axis.imshow(grid, origin="lower", extent=[angles[0], angles[-1], angles[0], angles[-1]], cmap="viridis") axis.set(title=f"thumb tip {label} in TCP frame (cm)", xlabel="motor8 (deg)", ylabel="motor7 (deg)") figure.colorbar(image, ax=axis) figure.tight_layout() figure.savefig(args.png, dpi=110)
if __name__ == "__main__": main()tools/grasp_diag.py+4-3
tools/thumb_map.pyAdded+80