"""Probe the Isaac task: zero residual, no offsets; compare joint tracking and the torch FK with PhysX body poses. isaaclab.bat -p probe_env.py (PYTHONPATH: package/simulation/isaac; SIM01_DEMO_LIB set) Simulation-tested ยท Not built. """ import argparse import json from isaaclab.app import add_launcher_args, launch_simulation parser = argparse.ArgumentParser() parser.add_argument("out") add_launcher_args(parser) args = parser.parse_args() import gymnasium as gym # noqa: E402 import torch # noqa: E402 import sim01_isaac # noqa: E402,F401 from sim01_isaac.env_cfg import P, ResidualPassEnvCfg # noqa: E402 cfg = ResidualPassEnvCfg() cfg.scene.num_envs = 4 args.device = cfg.sim.device with launch_simulation(cfg, args): env = gym.make("Isaac-Sim01-ResidualPass-v0", cfg=cfg) u = env.unwrapped env.reset() u.delta[:] = 0.0 u.vis_bias[:] = 0.0 u.latency[:] = 0 r = u.robot rows = [] gid = r.find_bodies("R_gripper")[0][0] bid = r.find_bodies("R_base")[0][0] with torch.inference_mode(): for k in range(300): env.step(torch.zeros(4, 5, device=u.device)) if k % 25 == 0: q = u._q_true() ref = u._ref(u.k) pg = r.data.body_link_pos_w.torch[:, gid] - r.data.body_link_pos_w.torch[:, bid] qb = r.data.body_link_quat_w.torch[:, bid] # x, y, z, w x, y, z, w = qb.unbind(-1) Rb = torch.stack([1 - 2 * (y * y + z * z), 2 * (x * y - w * z), 2 * (x * z + w * y), 2 * (x * y + w * z), 1 - 2 * (x * x + z * z), 2 * (y * z - w * x), 2 * (x * z - w * y), 2 * (y * z + w * x), 1 - 2 * (x * x + y * y)], -1).reshape(-1, 3, 3) pg_b = (Rb.transpose(1, 2) @ pg[:, :, None]).squeeze(-1) p_fk, _ = u.fk.gripper(q) rows.append({"k": k, "q": q[0].tolist(), "ref": ref[0].tolist(), "q_minus_ref": (q - ref)[0].tolist(), "gripper_isaac_base_frame": pg_b[0].tolist(), "gripper_fk": p_fk[0].tolist(), "fk_err_mm": float(1000 * (pg_b[0] - p_fk[0]).norm()), "joint_names": [r.joint_names[i] for i in u.ja.tolist()]}) json.dump(rows, open(args.out, "w"), indent=1) print("probe written", rows[-1]["fk_err_mm"], rows[-1]["q_minus_ref"]) env.close()