Skip to content

Newton gear insertion - #6833

Open
curiep wants to merge 4 commits into
isaac-sim:developfrom
shauryadNv:curiep/newton-gear-insertion
Open

Newton gear insertion#6833
curiep wants to merge 4 commits into
isaac-sim:developfrom
shauryadNv:curiep/newton-gear-insertion

Conversation

@curiep

@curiep curiep commented Jul 31, 2026

Copy link
Copy Markdown

Description

This PR adds Newton physics support to the Flexiv Rizon 4s gear-assembly
task while preserving the existing PhysX behavior.

  • Added Newton point-SDF and hydroelastic-SDF physics presets.
  • Added package-local concave collision assets that preserve gear bores and
    gear-base shafts instead of approximating them with convex hulls.
  • Corrected gear reset poses, shaft target poses, and coordinate-frame
    composition for randomized gear-base poses.
  • Made reset, reward, and drop detection consistently use the midpoint
    between the fingertips as the physical grasp frame.
  • Added physical Grav gripper actuation, passive-knuckle PD behavior, and
    solver-native arm gravity compensation without rewriting the selected
    gear pose.
  • Preserved the measured-state-relative 7-D joint-position action convention.
  • Added a separate 6-D Newton IK task variant for task-space policies.
  • Added configuration regression tests, documentation, and a changelog
    fragment.

Motivation and Context

The PhysX-authored task relied on collision and asset conventions that did
not transfer directly to Newton. In particular, convex approximations closed
concave gear geometry, reset and reward targets used inconsistent frames, and
the gripper linkage required explicit passive-joint behavior.

These changes provide a physical Newton training path for contact-rich gear
insertion without a pose-rewrite stabilization action. PhysX defaults remain
unchanged.

Fixes: N/A (no tracking issue was provided).

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Documentation update

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have added a changelog fragment under source/<pkg>/changelog.d/ for every touched package (do not edit CHANGELOG.rst or bump extension.toml — CI handles that)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

curiep added 3 commits July 31, 2026 10:00
Add Newton point-SDF and hydroelastic presets, local concave collision assets, and backend-specific reset, reward, and gripper configuration for Rizon 4s gear assembly.

Keep PhysX behavior unchanged, document Newton training, and add configuration regression coverage plus a flange IK variant.
Raise the per-rank triangle-pair capacity above the measured reset peak so 256-environment shards do not discard candidate contacts. Document the sizing assumption and cover it in the task configuration test.
@curiep
curiep requested a review from a team July 31, 2026 20:18
@github-actions github-actions Bot added documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team labels Jul 31, 2026
@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds Newton support for the Rizon 4s gear-assembly task.

  • Introduces point-SDF, hydroelastic-SDF, and MuJoCo-contact Newton physics presets with package-local concave collision assets.
  • Adds backend-specific reset poses, shaft targets, fingertip-centered grasp handling, gripper actuation, and arm gravity compensation while retaining PhysX defaults.
  • Registers a Newton inverse-kinematics task variant and adds configuration and asset regression tests.
  • Updates training documentation, contributor attribution, and the task changelog.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking defects identified.

The backend presets preserve existing PhysX configuration while coherently selecting Newton-specific assets, timing, reset behavior, contact handling, and action variants, with regression tests covering the principal configuration contracts.

Important Files Changed

Filename Overview
source/isaaclab_tasks/isaaclab_tasks/contrib/deploy/gear_assembly/gear_assembly_env_cfg.py Adds backend-resolved physics settings, local Newton collision assets, replication behavior, timing, and shaft-offset propagation.
source/isaaclab_tasks/isaaclab_tasks/contrib/deploy/gear_assembly/config/rizon_4s/joint_pos_env_cfg.py Specializes the Rizon task with Newton poses, actuators, gravity compensation, gripper behavior, and fingertip-centered task parameters while preserving PhysX values.
source/isaaclab_tasks/isaaclab_tasks/contrib/deploy/gear_assembly/config/rizon_4s/ik_newton_env_cfg.py Adds a six-dimensional relative Newton IK action targeting the physical flange.
source/isaaclab_tasks/isaaclab_tasks/contrib/deploy/mdp/events.py Updates reset-frame composition, named gripper-joint handling, and continuous seating of unselected gears.
source/isaaclab_tasks/isaaclab_tasks/contrib/deploy/mdp/rewards.py Adds shaft-relative insertion targets and optional fingertip-midpoint grasp tracking.
source/isaaclab_tasks/isaaclab_tasks/contrib/deploy/mdp/terminations.py Makes Newton drop detection measure distance from the physical fingertip midpoint.
source/isaaclab_tasks/test/contrib/test_deploy_gear_assembly_cfg.py Adds regression coverage for preset resolution, local SDF metadata, physical gripper configuration, shaft targets, and Newton IK.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    CLI[Training task and preset] --> Registry[Gym task registration]
    Registry --> Config[Rizon 4s environment config]
    Config --> Backend{Resolved physics preset}
    Backend -->|default or physx| PhysX[PhysX assets and behavior]
    Backend -->|newton_mjwarp| MJWarp[Newton with MuJoCo contacts]
    Backend -->|newton_sdf| SDF[Newton point-SDF contacts]
    Backend -->|newton_hydroelastic| Hydro[Newton hydroelastic-SDF contacts]
    SDF --> LocalAssets[Package-local concave gear assets]
    Hydro --> LocalAssets
    Config --> Reset[Backend-specific reset and shaft frames]
    Config --> Grasp[Fingertip-centered grasp, reward, and drop frames]
    Config --> Actions{Action variant}
    Actions --> Joint[7-D relative joint actions]
    Actions --> IK[6-D Newton flange IK actions]
Loading

Reviews (1): Last reviewed commit: "Add Curie Park to contributors" | Re-trigger Greptile

Use one centered collision mesh set for PhysX and Newton while
preserving the legacy PhysX asset frames for existing checkpoints.
Select Newton hydroelastic behavior at spawn time and expose an
explicit PhysX SDF validation preset.
@AntoineRichard AntoineRichard changed the title Curiep/newton gear insertion Newton gear insertion Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DOes this USDA need to live within IsaacLab? Could it be on Nucleus?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this USDA need to live within IsaacLab? Could it be on Nucleus?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this USDA need to live within IsaacLab? Could it be on Nucleus?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this USDA need to live within IsaacLab? Could it be on Nucleus?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this USDA need to live within IsaacLab? Could it be on Nucleus?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this USDA need to live within IsaacLab? Could it be on Nucleus?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this USDA need to live within IsaacLab? Could it be on Nucleus?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this USDA need to live within IsaacLab? Could it be on Nucleus?

@AntoineRichard AntoineRichard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated review.

Requesting changes before this showroom task is merged. I confirmed two incompatible defaults that the current tests miss: the Newton-IK task resolves to PhysX and still passes validation, and Newton collision capacity is sized/documented for 256 environments while the task defaults to 4,096. The every-step gear-pinning path also performs avoidable CUDA allocations and host synchronizations.

Please also consolidate the duplicated reset/placement logic, keep comments and docs functional rather than recording tuning history, and replace brittle configuration-literal assertions with behavioral regressions for frame composition, selected-vs-unselected gear handling, and fingertip-midpoint behavior.

Verification performed on commit 1ea7a1e:

  • all pre-commit hooks passed;
  • test_deploy_gear_assembly_cfg.py: 6 passed;
  • focused config check confirmed PhysxCfg + NewtonInverseKinematicsActionCfg passes validation;
  • focused config check confirmed Newton resolves to 4,096 environments with max_triangle_pairs=4,194,304.

I did not run GPU simulation or training.


# A 256-world GPU shard reached 1.54M broad-phase pairs during randomized resets.
# Keep power-of-two headroom so reset spikes do not discard candidate contacts.
_GEAR_MAX_TRIANGLE_PAIRS = 4_194_304

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated review — Important: this capacity is justified from a 256-environment shard, but the resolved Newton task still defaults to scene.num_envs == 4096 (confirmed locally). Running the task with only presets=newton_sdf or presets=newton_hydroelastic therefore violates this assumption and can silently discard candidate contacts. Set a Newton-specific environment default, size/derive the capacity for the actual default, or validate the supported shard size. The code comment should state the functional limit and overflow behavior; keep the 1.54M measurement and power-of-two selection history in benchmark/PR notes.

solver_cfg=MJWarpSolverCfg(
solver="newton",
integrator="implicitfast",
# The hydroelastic SDF pipeline produces distributed contact areas (thousands of points

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated review — Moderate: this comment narrates the tuning exercise and compares presets rather than documenting a durable invariant. Please reduce it to the functional fact (for example, hydroelastic contacts require larger per-world contact/constraint buffers); the measured contact count and why 4096 was selected belong in benchmark evidence, not production comments.


# Grav gripper actuator configuration for gear manipulation
self.scene.robot.actuators["gripper_drive"] = ImplicitActuatorCfg(
# Use the validated bare-arm gains for Newton while preserving the existing PhysX gains.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated review — Moderate: “validated bare-arm gains” is unverifiable here and does not explain code behavior. Remove the claim or make the comment functional (for example, “Use backend-specific arm actuator gains”); validation evidence and tuning history should live in tests/benchmarks or the PR.

__all__ = [
"randomize_gear_type",
"randomize_gears_and_base_pose",
"pin_unselected_gears_to_shafts",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated review — Moderate: this helper is only consumed by the Rizon task configuration, but exporting it from the public mdp stub creates a compatibility commitment—removing it later would require deprecation. Keep this task-specific workaround internal and import it from .events unless external users genuinely need a supported public API.



@configclass
class Rizon4sGearAssemblyIKNewtonEnvCfg(joint_pos_env_cfg.Rizon4sGearAssemblyEnvCfg):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated review — Important: this class inherits the PhysX default. I confirmed that resolving the registered Newton-IK task with default produces PhysxCfg + NewtonInverseKinematicsActionCfg, and cfg.validate() still passes, despite the docstring saying the combination is unsupported. Make the task select Newton by default or add a validate_config() backend/action compatibility check, and add a negative regression test for the unsupported combination.


for gear_idx, asset_name in enumerate(gear_asset_names):
mask = selected_gear_indices != gear_idx
if not torch.any(mask):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated review — Important: converting torch.any(mask) to a Python boolean forces a CUDA-to-host synchronization for each gear on every control step. Avoid data-dependent Python branching here; masked indexed writes already handle empty masks, or precompute/cache the environment groups.

assert hydro_cfg.scene.factory_gear_small.spawn.usd_path.endswith("factory_gear_small_hydroelastic.usda")


def test_rizon_gear_uses_shaft_targets_relative_actions_and_physical_gripper():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated review — Important: these new tests assert configuration wiring and selected literals, but none executes the behaviors this PR says it fixes. Add regressions that fail without the fix: rotate/translate the base and verify reset shaft poses through frame composition; verify the pin term writes only non-selected gears; and verify reward/drop distance uses the fingertip midpoint. Remove literal snapshots that do not protect one of those contracts.

sdf_prims = [prim for prim in stage.Traverse() if prim.HasAttribute("newton:sdfMaxResolution")]

assert len(sdf_prims) == 1
assert sdf_prims[0].GetAttribute("newton:sdfMaxResolution").Get() == 128

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated review — Moderate: pinning sdfMaxResolution == 128 freezes a tuning choice, and the test still cannot prove the docstring’s concavity claim—any mesh with these attributes passes. Either make this a metadata test and assert only the required schema/hydroelastic switch, or add a geometric assertion that actually protects the bore/concavity contract.


.. code-block:: bash

uv run isaaclab train --rl_library rsl_rl \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated review — Important: this is under “Full-Scale Training with Video Recording,” but the Newton command does not pass --video, --video_length, or --video_interval; the later command breakdown nevertheless describes Newton video length. Add a supported Newton recording command or separate this into a headless-training section and remove the video claims.

--visualizer none \
presets=newton_hydroelastic

The Newton hydroelastic preset uses package-local concave SDF collision assets. Its defaults

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated review — Moderate: this paragraph duplicates implementation details already encoded in the config/tests (dt, substeps, decimation, gap, gravity compensation, actuator behavior) and will drift as tuning changes. Keep the user-actionable distinctions—how to choose the preset and what to do on overflow—and remove the internal configuration narrative and exact-value rationale.

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

Labels

documentation Improvements or additions to documentation isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants