Use app look in scene

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-26 10:34:59 +09:00
co-authored by Claude Opus 5.5
parent 606d0907c8
commit be2b33e542
2 changed files with 125 additions and 29 deletions
+31 -8
View File
@@ -7,8 +7,10 @@ readings and taught points carry over without conversion.
- Arm joints: the fitted kinematics (data/arm_kinematics.json, robot/kinematics.py): each joint's frame
and zero corrected to the controller's own answers (0.2 mm). A joint's qpos is the controller's angle in radians.
- Arm meshes: JAKA's MiniCobo STEP (sim/sorting/assets/minicobo, the same files the Lumi app draws), placed with the
app's link chain (Lumi-app src/lib/armFrame.ts, fitted to the controller within ~1 mm).
- Look: the Lumi app's own 3D model (app_look.py: shell, trim, visor, red bands, green ring, JAKA lettering,
cutshion logo, cameras, lamp), each part in its link's frame; the arm's parts placed with the app's link chain
(Lumi-app src/lib/armFrame.ts, fitted to the controller within ~1 mm).
- Arm collision: JAKA's MiniCobo STEP meshes (sim/sorting/assets/minicobo, the arm in the app model).
- Torso, lift, head, base: the vendor URDF meshes, placed from the arm through the URDF chain at the sorting pose
(lift LIFT_M, waist WAIST_RAD, head straight).
- Torso camera: the hand-eye calibration (data/camera_extrinsics.json), fovy from the factory intrinsics.
@@ -26,6 +28,8 @@ from pathlib import Path
import mujoco
import numpy as np
import app_look
HERE = Path(__file__).resolve().parent
SIM = HERE.parent
REPO = SIM.parent
@@ -276,12 +280,25 @@ def build():
x.append(' <!-- generated by sim/sorting/build.py: edit that file, not this one -->')
x.append(' <compiler angle="radian" autolimits="true"/>')
x.append(' <option timestep="0.002" integrator="implicitfast" cone="elliptic" impratio="10"/>')
x.append(' <visual><global offwidth="1280" offheight="960"/><quality shadowsize="4096"/></visual>')
# an office: light walls all round and soft light from everywhere, so the white shell reads white
x.append(' <visual><global offwidth="1280" offheight="960"/><quality shadowsize="4096"/>'
'<headlight ambient="0.45 0.45 0.45" diffuse="0.35 0.35 0.35" specular="0.1 0.1 0.1"/></visual>')
x.append(' <asset>')
for i in range(1, 7):
x.append(f' <mesh name="mc_a{i}" file="assets/minicobo/link_a{i}.stl"/>')
for name in sorted({g[1] for g in tgeoms if g[0] == "mesh"}):
x.append(f' <mesh name="{name}" file="../lumi_description/meshes/{meshfile[name]}"/>')
look = app_look.parts()
by_link = {}
for k, part in enumerate(look):
name = f"app{k}_{part['link']}_{part['material']}"
by_link.setdefault(part["link"], []).append(name)
x.append(f' <mesh name="{name}" file="{part["file"]}" inertia="shell"/>') # looks only: thin decals have no volume
tex = ""
if part["texture"]:
x.append(f' <texture name="tex_{name}" type="2d" file="{part["texture"]}"/>')
tex = f' texture="tex_{name}"'
x.append(f' <material name="{name}" rgba="{fmt(part["rgba"])}" specular="{part["specular"]}" '
f'shininess="{part["shininess"]}"{tex}/>')
x.append(' <texture name="sky" type="skybox" builtin="gradient" rgb1="0.93 0.93 0.92" rgb2="0.78 0.79 0.80" width="512" height="512"/>')
x.append(' <texture name="grid" type="2d" builtin="checker" rgb1="0.82 0.82 0.80" rgb2="0.76 0.76 0.74" width="512" height="512"/>')
x.append(' <material name="floor" texture="grid" texrepeat="8 8"/>')
for name, rgba in (("white", "0.92 0.93 0.94 1"), ("black", "0.08 0.08 0.09 1"), ("alu", "0.75 0.76 0.78 1"),
@@ -303,6 +320,7 @@ def build():
x.append(' <worldbody>')
x.append(' <light pos="0 0.5 1.6" dir="0 0 -1" diffuse="0.8 0.8 0.8" castshadow="true"/>')
x.append(' <light pos="-1 -1 1.2" dir="1 1 -1" diffuse="0.35 0.35 0.35"/>')
x.append(' <light pos="0.3 2.0 0.8" dir="-0.1 -1 -0.4" diffuse="0.45 0.45 0.45"/>') # from Lumi's front
floor_z = FLOOR_Z
x.append(f' <geom name="floor" type="plane" pos="0 0 {floor_z:.3f}" size="3 3 0.05" material="floor"/>')
x.append(f' <camera name="torso_cam" pos="{fmt(cam_t)}" xyaxes="{fmt(cam_R[:, 0])} {fmt(-cam_R[:, 1])}" fovy="{fovy:.2f}"/>')
@@ -312,8 +330,9 @@ def build():
# torso, lift, head and base, fixed at the sorting pose
x.append(f' <body name="torso" {pose_attr(T2)}>')
for i, (kind, mesh, Tg, size, mat) in enumerate(tgeoms):
if kind == "mesh":
x.append(f' <geom class="visual" mesh="{mesh}" {pose_attr(Tg)} material="{mat}"/>')
if kind == "mesh": # the URDF link's frame here: the app's parts of that link go on it
for name in by_link.get(mesh, []):
x.append(f' <geom class="visual" mesh="{name}" {pose_attr(Tg)} material="{name}"/>')
else:
x.append(f' <geom class="body_col" type="{kind}" {pose_attr(Tg)} size="{fmt(size[:3 if kind == "box" else 2])}"/>')
x.append(' </body>')
@@ -327,7 +346,11 @@ def build():
x.append(f'{ind} <inertial pos="0 0 0.05" mass="{[1.35, 1.6, 1.1, 0.7, 0.7, 0.3][i]}" diaginertia="0.005 0.005 0.002"/>')
lim = math.radians(limits[i])
x.append(f'{ind} <joint name="j{i + 1}" axis="0 0 1" range="{-lim:.4f} {lim:.4f}" armature="0.1" damping="2"/>')
x.append(f'{ind} <geom class="visual" mesh="mc_a{i + 1}" {pose_attr(offsets[i])} material="white"/>')
for name in by_link[f"link_a{i + 1}"]:
x.append(f'{ind} <geom class="visual" mesh="{name}" {pose_attr(offsets[i])} material="{name}"/>')
if i == 5: # the flange plate (link_at): 36 mm out along link_a6's z
for name in by_link["link_at"]:
x.append(f'{ind} <geom class="visual" mesh="{name}" {pose_attr(offsets[i] @ hmat(np.eye(3), [0, 0, 0.036]))} material="{name}"/>')
x.append(f'{ind} <geom group="3" type="mesh" mesh="mc_a{i + 1}" {pose_attr(offsets[i])} density="0" rgba="0.4 0.6 0.9 0.3"/>')
ind += " "
x.append(f'{ind}<site name="flange" size="0.005" group="4"/>')