# Isaac runbook: DIY AR Glasses (robot/robot.usd)

**Simulation-tested · Not built.**

The design has no learned controller, so RL-ISAAC, RL-SIM2SIM and POLICY-PLAYABLE are N/A (docs/PLAN.md). Isaac tooling is used only to make `robot/robot.usd` from the URDF and to check that it loads in Isaac Sim PhysX. Isaac Lab runs in its own Python, never in the project's uv environment. Only files cross between them:
- in: `robot/robot.urdf`, `robot/meshes/**` and `simulation/isaac/usd_params.json`;
- out: `robot/robot.usd`, `docs/sim-tests/usd_dump.json` and `docs/sim-tests/usd_load.json`.

## Environment used (2026-10-11)

- Windows 11, NVIDIA GeForce RTX 5060 Ti (16 GB), Warp 1.16.0 with CUDA Toolkit 12.9 and driver CUDA 13.1.
- Isaac Lab 3.0.0 at `C:\isaac-sim\IsaacLab`. Its `_isaac_sim` links to Isaac Sim 6.1.0-rc.26 at `C:\isaacsim` (Kit 110.3.0).
- URDF importer: `isaacsim.asset.importer.urdf` 3.0 (urdf-usd-converter 0.3.2), called through `isaaclab.sim.converters.UrdfConverter`.

## Commands

Run from the repo root. `tasks.py usd` needs the **GPU queue slot**.

```
uv run tasks.py usd                 # params -> Isaac (convert, flatten, author, dump, PhysX load test) -> model checks
uv run tasks.py usd --params-only   # write simulation/isaac/usd_params.json only (no GPU)
uv run tasks.py usd --checks-only   # re-run src/model_checks.py on the committed robot.usd and dumps (no GPU)
```

Without uv, the same steps by hand:

```
REM 1. Isaac config from spec.yaml + cad/parts.json (project venv)
set PYTHONPATH=package\src
python -m cmds.usd --params-only                        (cwd: package\src)

REM 2. Isaac Lab's own Python: VIRTUAL_ENV and PYTHONPATH must be unset
set VIRTUAL_ENV=
set PYTHONPATH=
cd /d C:\isaac-sim\IsaacLab
isaaclab.bat -p "<repo>\package\simulation\isaac\tools\urdf_to_usd.py" "<repo>\package\simulation\isaac\usd_params.json"
REM    add --skip_load_test to convert and dump only (usd_load.json then says NOT RUN)

REM 3. Consistency columns + overall MODEL-LOAD / MODEL-CONSIST (project venv)
python -m cmds.usd --checks-only                        (cwd: package\src)
```

The run takes about 1 minute: Kit start about 5 s, conversion about 2 s, 3000 PhysX steps about 40 s. Exit code 0 means it ran. Exit code 3 means the load test ran and FAILed; `usd_load.json` holds the reason.

## What the tool does

`tools/urdf_to_usd.py`, with every number from `usd_params.json`:
1. **Convert.** `UrdfConverter`: floating base (`fix_base` False), no fixed-joint merging, self-collision on, URDF collision primitives kept (no collision from visuals). The output goes to `runs/usd_import/` (git-ignored).
2. **Flatten.** Select the importer's `physx` Physics variant, de-instance, then flatten to one self-contained `robot/robot.usd` (crate format, Git LFS). The tool checks that no external asset paths remain. Identical inputs give a byte-identical file.
3. **Author the Isaac config.** USD measures revolute joints in degrees, so angular gains are per degree.
   - **SG90 servos** (`visor_flip`, `focus`):
     - position drive with kp = stall / 3° band, kd = stall / no-load speed + joint damping;
     - maxForce = stall torque at the rail;
     - PhysX armature and maxJointVelocity.
   - **Temple hinges:** the clamp spring is a drive toward springref, with no force cap.
   - **focus_slide:**
     - the importer's `NewtonMimicAPI` is kept, with `coef1` re-authored in m/deg (DESIGN_LOG D17);
     - the carriage preload spring is a drive toward its springref.
   - **Articulation:** self-collisions on.
   - **Joint friction:** Coulomb friction (MJCF frictionloss) is only in `newton:friction` and the custom attribute `zmass:frictionloss`. PhysX's `jointFriction` is a coefficient on the constraint force, not a torque, so it is not authored.
4. **Dump** to `docs/sim-tests/usd_dump.json`: links (mass, CoM, principal inertia, collision and visual counts) and joints (axis token, frames, limits, drives, mimic in SI).
5. **PhysX load test** to `docs/sim-tests/usd_load.json`, with gravity on and dt = spec `control.sim_dt_s`:
   - a floating copy is dropped onto a ground plane;
   - a second copy is held by a runtime world fixed joint kept out of the articulation, and its servos are commanded to 75% of their ranges.
   - **PASS when** the asset spawns with the URDF's 6 bodies and 5 joints, keeps all 185 collision primitives and 29 visuals, is self-contained, stays finite for 3000 steps, and the file is under ZMass's 200 MB per-file limit.
   - Servo tracking, the coupling error and the hinge rest angle are information.

## Known importer behaviour (Isaac Sim 6.1.0-rc.26, importer 3.0)

- **Mimic units.** The importer writes the URDF mimic multiplier unchanged into `newton:mimicCoef1`. The PhysX runtime applies `follower = coef0 + coef1 * leader` in USD units, where the revolute leader is in degrees. For `focus_slide` (prismatic, m) following `focus` (revolute), the raw value locked the cam at focus = 1.047° in the first load test. The tool re-authors `coef1` = multiplier × π/180. MODEL-CONSIST compares the mimic converted back to SI against the URDF, so a regression shows up as a FAIL.
- **Fixed root.** `ArticulationRootPropertiesCfg(fix_root_link=True)` fails on this asset: it cannot remove `newton:selfCollisionEnabled` from the referenced layer. The load test uses a world fixed joint that is excluded from the articulation.
- **Root prim name.** The prim is named `/tn__diyarglasses_zH6`, the importer's tokenized form of `diy-ar-glasses`. Spawn the asset through its default prim; do not hard-code that path.
- **Drive gains.** The importer warns "Stiffness and damping not available ... actuator will be created without gain parameters" for the MuJoCo variant's actuators because the converter is called with gains 0. The gains are authored in step 3 on the flattened `physx` variant. The `mujoco` variant is not kept in robot.usd; ZMass and Phase 4 use `robot/robot.xml`.
