Skip to content

Minor fixes for DisplayPort cable insertion envs - #10

Open
j3soon wants to merge 81 commits into
shauryadNv:shauryad/dp_cable_shipfrom
j3soon:j3soon/fix/dp_cable_ship
Open

j3soon wants to merge 81 commits into
shauryadNv:shauryad/dp_cable_shipfrom
j3soon:j3soon/fix/dp_cable_ship

Conversation

@j3soon

@j3soon j3soon commented Sep 3, 2026

Copy link
Copy Markdown

No description provided.

curiep and others added 30 commits August 26, 2026 09:28
The Rizon 4s cable-insertion task was failing every episode at reset:
the IK + open-loop close sequence put the gripper next to the plug
instead of around it, the fingers closed on empty space, and the
plug fell to the floor (or twisted away when a finger clipped its
edge).

Root cause was a geometry mismatch between the un-flattened plug USD
and the IK target. The un-flattened plug has its visible/collision
``Mesh`` offset ~3 cm from the rigid-body origin
(``bbox_center_local = (0.0312, 0.0009, -0.0107)`` in body frame).
``set_robot_to_object_grasp_pose`` snapped the plug body to the
gripper-achieved pose, but the achieved pose was a function of the
*body* origin, not the visible centre, so the fingertips landed
~3 cm from the actual plug.

Switch to the flattened plug + socket USDs (``flattened/`` directory)
where ``bbox_center == (0, 0, 0)`` and the visible mesh coincides
with the rigid-body origin. With that, the grasp parameters reduce
to the gripper tool length only:

* ``grasp_offset = (0, 0, -0.13)`` -- only backs ``link7`` off by
  the Grav tool length so the fingertips land at the plug body
  origin (which is now also the visible centre).
* ``grasp_rot_offset = (-0.707, 0.707, 0, 0)`` (unchanged) keeps
  ``link7`` pointing straight down with the gripper finger axis
  perpendicular to the plug's long body Y axis.
* Plug + socket use identity ``init_state.rot``; the flattened USDs
  already align the long axis with body Y.
* Plug spawns 5 cm above the socket so the policy has descent room.
* ``hand_close_width = 0.0`` matches the gear-assembly small-gear
  close target. ``-0.155`` (the joint hard limit) was tried and
  ejected the plug because the drive over-commanded the fingers.

Also extend ``set_robot_to_object_grasp_pose``:

* Snap the held object to the achieved hand pose after IK so any
  IK residual error or geometry offset is washed out before the
  gripper closes.
* One-shot ``[GRASP-DBG]`` log dumps the initial pose, the IK
  target, the achieved hand pose and the snapped object pose --
  invaluable for diagnosing future grasp regressions.
The Flexiv Rizon 4s in the NVIDIA Hubble Lab is wall-mounted with the
arm rotated about the negative X-axis. Update the ROS inference env
config so the simulator's reset state matches the physical robot:

* Set the home joint pose to the lab's joint convention.
* Set the robot base orientation to the wall-mount quaternion so the
  arm hangs the same way in sim and in the real cell.

This keeps the policy roll-out and the live deployment in the same
robot frame, which is required for the policy obs (computed relative
to ``base_link``) to be valid at inference time.
Three small scripts under ``scripts/tools/`` to diagnose and repair
USD assets whose visible/collision geometry is offset from the
rigid-body origin -- the failure mode that broke the Rizon 4s
cable-insertion grasp.

* ``inspect_cable_usd.py``: standalone Pixar-USD walker. Lists xform
  ops, ``RigidBodyAPI`` / ``MassAPI`` / ``CollisionAPI`` markers and
  per-mesh ``bbox_center_local`` / ``bbox_size``. Use this from any
  shell that already has ``pxr`` on PYTHONPATH (e.g. a Kit Python).

* ``inspect_cable_usd_kit.py``: same walker run inside an IsaacLab
  ``AppLauncher`` context so ``pxr`` is available without extra setup.
  This is what we actually used during debugging from the IsaacLab
  conda env.

* ``flatten_cable_usd.py``: bake the chain of intermediate xforms
  down into the leaf mesh's points, then reset all xform ops on the
  rigid-body and its children to identity. The result is a USD whose
  visible mesh is centered at the rigid-body origin -- exactly the
  invariant the IK-based grasp event assumes. Supports an optional
  ``--rotate-z-deg`` knob for assets whose body-local pose needs an
  additional rotation baked in.

Both inspectors print the bounding-box centre in body-local frame so
``grasp_offset`` can be set deterministically from the asset rather
than tuned by trial and error.
Required for training: env cfg references these files but they were
excluded by the *.usd gitignore rule.
shauryadNv and others added 25 commits August 26, 2026 09:31
Remove debug scripts, asset tooling, passive drop-test env, legacy GB300
configs, unused assets, and disabled sysid action plumbing. Keep only the
displayport_rizon_4s joint/task/ROS env variants and the two SDF USD assets
used by the training envs.
Activate the measured-kinematics Rizon4s USD (added under display_cable_insertion_assets) as the robot spawn USD in place of the stock Nucleus rizon4s_with_grav.usd, for sim-to-real calibration experiments.
Adds an operational-space-control variant of the DisplayPort cable
insertion task alongside the existing joint-space environments, plus the
export path needed to deploy it through Isaac ROS.

The policy commands a 6-DoF Cartesian pose delta instead of joint
targets. The actor observes the gripper TCP (flange + 192.5 mm) while the
controller acts on the flange, matching the frames the trained
checkpoints use. Arm PD gains are zeroed because OSC commands joint
efforts; an active joint PD would hold its reset target and override
them.

Deploy action wrappers mark their processed actions for export so the
LEAPP graph carries the scaled Cartesian delta with proper semantics
rather than an unlabelled tensor. The annotator honours that metadata and
lets the processed action replace per-asset write outputs.

Export reuses the RSL-RL LEAPP exporter behind --task_space_contract,
which splits the 18-D observation into named pose tensors
(eef_pos, eef_rot_6d, socket_kp_pos, socket_kp_rot_6d) and emits
arm_action. That contract annotates its own graph node, so it bypasses
the automatic env patcher, aligns the recurrent-state node name, and
annotates inputs before the state tensors are registered.

Verified on the ship branch: task registration, training on the
task-space and ROS-inference variants, and an export whose artifacts are
byte-identical to the previous standalone script.
The previous commit inadvertently included in-progress documentation and
export entries for `sysid_cfg.py` and `delayed_joint_actions*.py`, which
are not part of this branch. This left the docs describing files a fresh
clone does not have, and `mdp/__init__.pyi` lazily exporting six symbols
from an absent module (accessing any of them raised ModuleNotFoundError;
no committed code referenced them).

Removes the "Sim-to-Real / SysID Action Model" section, the two Code
Layout entries, and the six `Delayed*`/`FlexivDynamicsAware*` stub
exports. The task-space (OSC) work from the previous commit is unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Review feedback: `scripts/reinforcement_learning/leapp/rsl_rl/export.py` is a
generic, user-facing entry point (like train.py / play.py) and should stay
task-agnostic, and task-specific processed-action semantics should not be
injected into the core library.

Both shared files are restored to upstream verbatim:
  - scripts/reinforcement_learning/leapp/rsl_rl/export.py
  - source/isaaclab/isaaclab/utils/leapp/export_annotator.py

The task-space contract now lives in a DisplayPort-specific exporter,
`export_displayport_insertion.py`, which reuses the generic flow and only
substitutes the export routine: `run_export_with_hydra` resolves
`export_rsl_rl_agent` as a module global, so rebinding it is sufficient.
Argument parsing, checkpoint resolution, Hydra config, runner construction
and graph compilation remain shared with upstream.

The annotator changes were reachable only via `patch_env_for_export`, which
the task-space path deliberately skips, so reverting them does not affect the
exported artifacts.

The `isaaclab` changelog fragment is dropped since the core library is no
longer modified.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The tutorial described the joint-space environments almost exclusively, even
though task-space (OSC) variants ship alongside them. It now presents both
control spaces side by side.

Content:
* Task details state that the policy observes the robot's current state (arm
  joint angles in joint space, flange/end-effector pose in task space), and
  that the output is a joint-position delta or a Cartesian pose delta.
* Notes that this environment has been deployed and tested on a real
  Flexiv Rizon 4s, matching the gear assembly tutorial.
* Observation, action, training, export and deployment-metadata sections are
  tabbed by control space; adds a "Choosing a Control Space" comparison.
* Documents the task-space specifics: 18-dim actor input, 6D rotation
  representation, zeroed joint PD gains, and the TCP-observe / flange-control
  split.
* Generalizes the proprioceptive-noise rationale to the task-space
  end-effector pose, and clarifies which observation carries perception noise.

Cleanup:
* Drops the SysID / delayed-action code-layout entries and section; that work
  is not part of this branch.
* Refers to the plug and socket assets generically instead of naming files
  under a specific directory.
* Adds the joint-space, task-space and exporter entries to the code layout.

Also carries four pre-existing wording fixes from the working tree
(Isaac ROS naming, "DisplayPort plug", "considerable").

Verified with a Sphinx build: 6 tab-sets / 12 tab-items render, and the
tutorial's rst pre-commit hooks pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…pace

Records two pieces of deployment guidance that were not written down:

* Task space is the recommended control space. Task-space policies have
  transferred better than joint-space ones in our testing on the real Flexiv
  Rizon 4s, because a Cartesian pose delta keeps the policy independent of the
  arm's joint servo behavior and of small kinematic-model errors.

* Joint-space training needs a robot USD that matches the specific arm. The
  policy commands joints directly, so kinematic mismatch surfaces as
  end-effector error at sub-millimetre clearances. Points at Flexiv's
  flexiv_calibration workflow for exporting a calibrated robot description, and
  documents the DP_ROBOT_USD environment variable for selecting the result.

The guidance appears in "Choosing a Control Space" (new anchor), with pointers
from the task details and Step 1, and a robot-asset paragraph in the asset
quality section.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Two corrections to the DisplayPort tutorial.

The "use the NoJointVel variant" note sat at the top level of the observation
section, so it read as the tutorial's overall sim-to-real recommendation while
actually only concerning the joint-space variants — and it competed with the
task-space recommendation. It now lives inside the joint-space tab, is worded
as a choice among the joint-space variants, and points at
"Choosing a Control Space" for the broader question.

The ROS-inference environments are the ones actually used to train deployed
policies, not just an export-time configuration. In addition to the training
setup they declare the metadata Isaac Manipulator and LEAPP consume and pin
the plug, socket and seed joint pose to the real deployment station, so
training on them means the trained environment and the exported contract are
identical and a checkpoint deploys with Isaac ROS without a config swap.

* Registered environments table is reordered around this: the two
  `-ROS-Inference-v0` ids lead as the training + deployment entries, with the
  plain ids described as experiment-only.
* Step 1 and Step 2 commands train on the `-ROS-Inference-v0` ids in both
  control spaces.
* Drops the "(optional)" framing that presented ROS-aligned metadata as an
  extra, and notes in the export section that no id swap is needed.

Sphinx build passes; all nine registered ids are documented.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`--export_method` defaults to `None` in argparse, and the task-space
contract branch forwarded it unchanged to LEAPP as `export_with=None`, so
no model was compiled. The export still exited 0 and printed a success
banner while writing a package with no `.onnx` graph and a null
`model_path`, and its validation step was skipped yet still counted as
passing. Following the tutorial, including the `--validation_steps` it
recommends, therefore produced a LEAPP package containing no policy and
reported success.

The same file already substitutes the `onnx-dynamo` default on the
observation-patching path. Hoist that resolution above the branch so both
call sites share one value.
The joint-space LEAPP export aborted on the default `onnx-dynamo` backend
for two independent reasons.

`rigid_object_quat_w` canonicalised the socket quaternion with
boolean-mask assignment, which lowers to the data-dependent
`aten.masked_select`; the ONNX exporter has no conversion for it. Use
`isaaclab.utils.math.quat_unique` instead, which is a branchless
`torch.where` with identical semantics and the same `(x, y, z, w)`
convention. The task-space observation group was unaffected because it
uses the 6D rotation term.

With that resolved the graph built but was structurally invalid.
`JointAction` stores `find_joints` output as warp-backed `int32`, and ONNX
`GatherND` requires int64. Torch accepts int32 advanced indexing, so this
never surfaces at runtime and only appears once the term is traced for
export. The observation path already used a plain Python list, hence
int64, which is why only the action-side gather was rejected.
The tutorial tells the reader to calibrate their arm with Flexiv's
`flexiv_calibration` workflow, convert the result to USD, and select it
with the `DP_ROBOT_USD` environment variable, warning that a kinematic
mismatch shows up directly as end-effector error at sub-millimetre
insertion clearances.

Nothing read the variable. `_RIZON4S_CALIBRATED_USD_PATH` was an
unconditional module constant, so the environment always spawned the
shipped `Rizon4s-063459` asset and a calibrated user would only discover
the mismatch on hardware.

Add `resolve_robot_usd()` alongside the other shared task helpers and use
it in both control spaces. Defaults are unchanged: joint space keeps the
calibrated asset, task space keeps the robot's own `rizon4s_with_grav.usd`
since it never set a `usd_path`. Record that difference in the tutorial,
which described the calibrated asset as though both spaces used it.

The override is passed through to the spawner untouched so that remote
assets work, since a converted robot description may live on Nucleus or
behind an HTTP(S) URL rather than on local disk. The spawner already
resolves and downloads remote paths and raises `FileNotFoundError` naming
the path when one cannot be reached, so an unreachable value still fails
loudly without this helper having to guess what a valid path looks like.
`--headless` no longer exists: headless is the default and `--visualizer`
opts into a GUI. All five occurrences made their command fail immediately
with `unrecognized arguments: --headless`, even though Step 1 on the same
page already used the current flag. Remove them and reword the command
breakdown bullet that described the flag.

Removing it exposes the next stop: `--video` requires MoviePy, which the
container does not ship and the page never mentioned. Add the install
line.

Add the prerequisites the page lacked: a link to the installation guide,
the note that `logs/` is a named volume under the container workflow so
the checkpoint and TensorBoard paths used later do not resolve on the
host, and that the plug, socket and robot USDs ship via Git LFS.
The page listed the station constants for the training layout and the
joint-space deployment layout, but `task_space_ros_inference_env_cfg.py`
defines a third set. Task space is the recommended control space, so the
recommended deployment environment was the one whose station a reader was
never told to re-measure; editing the two documented files leaves it
unchanged.

The two deployment stations also differ, and the play section told the
reader its examples applied unchanged to a task-space policy while passing
the joint-space socket pose. On a task with sub-millimetre clearances that
evaluates the policy a centimetre from the station it was trained at. Give
the task-space example its own pose and note that the poses differ.
… run

Every section after training needs a `--checkpoint`, but the shipped agent
configuration writes one every 50 iterations. `model_0.pt` appears at
startup and is easy to mistake for a usable checkpoint, while the first
one reflecting any learning is `model_50.pt`, so a reader working through
the page has no way to reach the export and inference sections without
waiting out a long run first.

Record that `agent.save_interval` can be lowered to get there sooner, and
that a checkpoint taken that early exercises the export plumbing rather
than demonstrating the policy.
`DP_ROBOT_USD` is a user-visible capability of the environments this pull
request adds, so it belongs in the existing DisplayPort fragment rather
than in a fix note: the environments and the exporter ship for the first
time here, and describing corrections to them would report a defect no
release contained.

The joint index dtype is the same situation one package over. The
warp-backed `int32` form it corrects exists only on `develop`, so
`isaaclab` takes a `.skip` fragment to satisfy the per-package
requirement without inventing a release note.
The script fails `ruff`, `ruff format` and `codespell` as it stands, so
`uv run isaaclab -f` reports errors on a clean checkout and the hooks
block CI. None of the changes affect behaviour.

`ruff` and `ruff format` account for the import ordering and line
reflowing. The remaining three needed a decision rather than an
autofix:

* `try`/`except`/`pass` around the TensorDict clone becomes
  `contextlib.suppress(Exception)` (SIM105).
* `main` exceeds the configured mccabe limit, so it takes `# noqa: C901`
  as the other large entrypoints in the repository do, rather than being
  restructured here.
* `codespell` reads the local `rin` as a misspelling. Renaming it to
  `rnn_vals` keeps the shared `ignore-words-list` from having to absorb a
  three-letter token that could mask real typos elsewhere.
`DP_ROBOT_USD` was documented but unread, so nothing caught that the
environments ignored it. Cover the contract directly: both control spaces
honour the override, both keep their own default when it is unset, and a
blank value falls back rather than blanking out the robot.

The override is parametrised over a local path, an `omniverse://` URL and
an HTTP(S) URL, since a converted robot description need not live on local
disk and validating it as a filesystem path would reject the remote forms.

The defaults are asserted per control space because they genuinely differ:
joint space spawns the calibrated asset shipped with the task, task space
the stock arm.

The configurations build without Kit, so these run in ordinary collection
alongside the gear-assembly configuration tests.
@github-actions github-actions Bot added bug Something isn't working documentation Improvements or additions to documentation isaac-lab labels Sep 3, 2026
@shauryadNv
shauryadNv force-pushed the shauryad/dp_cable_ship branch from 015b113 to 0e6d1c7 Compare September 9, 2026 22:12

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation isaac-lab

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants