"""Pre-training check for Isaac-GolfCartDriver-PathFollow-v0: scripted actuator / vehicle run, mimic coupling, timing. Research and simulation project only. Do not install this device in a real vehicle or attempt to drive a vehicle with it. It has not been built or tested on any vehicle. Simulation-tested ยท Not built. isaaclab.bat -p probe_env.py [--num_envs 4] [--timing_envs 0] [--timing_steps 100] (PYTHONPATH: package/simulation/isaac) 1. Nominal envs (randomize off: V1, no noise, no disturbances, no latency): the scripted action sequence SCRIPT (policy actions held for the given seconds) is applied; every policy step records the kit joint positions, the slider / lever positions from the drums, the cart state, the motor torques, the throttle fraction and the brake deceleration capacity. src/isaac_mj_compare.py replays the same sequence in the MuJoCo harness (diagnostic). 2. Mimic coupling under PhysX with the spawn-time unit fix: follower vs leader x multiplier over the run. 3. Optional timing with --timing_envs N random-action envs (randomize on): environment steps per second. """ import argparse import json import sys import time sys.dont_write_bytecode = True from isaaclab.app import add_launcher_args, launch_simulation # noqa: E402 parser = argparse.ArgumentParser() parser.add_argument("out") parser.add_argument("--num_envs", type=int, default=4) parser.add_argument("--timing_envs", type=int, default=0) parser.add_argument("--timing_steps", type=int, default=100) parser.add_argument("--physics_dt", type=float, default=None, help="override the physics step (decimation follows)") add_launcher_args(parser) args = parser.parse_args() import gymnasium as gym # noqa: E402 import torch # noqa: E402 import golf_cart_isaac # noqa: E402,F401 from golf_cart_isaac.env_cfg import P, GolfCartPathFollowEnvCfg # noqa: E402 # (seconds, [steer, throttle, brake]) policy actions; the same list is replayed in MuJoCo by src/isaac_mj_compare.py SCRIPT = [(1.0, [0.0, 0.0, 0.0]), (4.0, [0.0, 0.35, 0.0]), (3.0, [0.3, 0.30, 0.0]), (2.0, [-0.3, 0.30, 0.0]), (3.0, [0.0, 0.0, 0.6]), (2.0, [0.0, 0.0, 0.0])] def main(): out = {"generated_by": "simulation/isaac/tools/probe_env.py", "task": P["task"], "backend": "PhysX (isaaclab_physx.physics.PhysxCfg)", "script": SCRIPT, "policy_hz": P["policy_hz"]} cfg = GolfCartPathFollowEnvCfg() cfg.scene.num_envs = args.timing_envs or args.num_envs if args.physics_dt: cfg.decimation = int(round(1.0 / (P["policy_hz"] * args.physics_dt))) cfg.sim.dt = args.physics_dt cfg.sim.render_interval = cfg.decimation out["physics_dt"] = args.physics_dt out["physics_dt"] = cfg.sim.dt if not args.timing_envs: cfg.randomize = False cfg.eval_mode = True cfg.terminate = False cfg.episode_length_s = sum(s for s, _ in SCRIPT) + 1.0 args.device = cfg.sim.device with launch_simulation(cfg, args): try: env = gym.make(P["task"], cfg=cfg) u = env.unwrapped if args.timing_envs: env.reset() with torch.inference_mode(): for _ in range(5): env.step(0.5 * torch.randn(u.num_envs, 3, device=u.device)) torch.cuda.synchronize() t0 = time.perf_counter() for _ in range(args.timing_steps): env.step(0.5 * torch.randn(u.num_envs, 3, device=u.device)) torch.cuda.synchronize() dt = time.perf_counter() - t0 out["timing"] = {"num_envs": args.timing_envs, "steps": args.timing_steps, "seconds": dt, "env_steps_per_s": args.timing_envs * args.timing_steps / dt, "s_per_iteration_rollout_24": 24 * dt / args.timing_steps, "gpu_mem_max_gb": torch.cuda.max_memory_allocated() / 1e9} env.close() return out["mimic_authored"] = {k: list(v) for k, v in list(u.mimic_authored.items())} env.reset() r = u.robot names = list(r.joint_names) out["joint_names"] = names rows, mimic = [], {"brake_slider_joint": [], "throttle_lever_joint": []} mim = P["kit"]["mimic"] t = 0.0 with torch.inference_mode(): for dur, a in SCRIPT: for _ in range(int(round(dur * P["policy_hz"]))): act = torch.tensor([a], device=u.device).repeat(u.num_envs, 1) env.step(act) t += 1.0 / P["policy_hz"] q = r.data.joint_pos.torch[0].tolist() rows.append({"t": round(t, 4), "action": a, "q": q, "slider": float(u.slider_s[0]), "v": float(u.v[0]), "x": float(u.x[0]), "y": float(u.y[0]), "yaw": float(u.yaw[0]), "tau": u.tau[0].tolist(), "thr_frac": float(u.thr_frac[0]), "brake_cap": float(u.brake_cap[0]), "target": u.target[0].tolist(), "pedal_b": float(u.pedal_b[0])}) for f, mm in mim.items(): lq = q[names.index(mm["leader"])] if abs(lq) > 1e-3: mimic[f].append(q[names.index(f)] / (lq * mm["multiplier"])) out["rows"] = rows out["mimic_ratio_to_urdf"] = {f: {"min": min(v), "max": max(v), "n": len(v)} if v else None for f, v in mimic.items()} out["finite"] = bool(all(all(abs(x) < 1e6 for x in rw["q"]) for rw in rows)) env.close() except BaseException: import traceback out["error"] = traceback.format_exc() raise finally: with open(args.out, "w", encoding="utf-8", newline="\n") as fh: json.dump(out, fh, indent=1) print("probe written", args.out, flush=True) main()