Skip to content

Accelerate and strengthen asset tests [6/13] - #8144

Closed
AntoineRichard wants to merge 28 commits into
isaac-sim:developfrom
AntoineRichard:antoiner/asset-tests-p11-physx-articulation-core
Closed

AntoineRichard wants to merge 28 commits into
isaac-sim:developfrom
AntoineRichard:antoiner/asset-tests-p11-physx-articulation-core

Conversation

@AntoineRichard

@AntoineRichard AntoineRichard commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Part 6/13 of the asset-test series (tracker: #7282). Scope: PhysX articulation. Depends on #8134, which brings in #8131; this branch contains their commits until they merge.

What changed

source/isaaclab_physx/test/assets/test_articulation.py now runs most checks on one module-scoped scene built from the local branching fixture (data/articulation_ordering_branching.usda) instead of per-test Nucleus robots. The test authors link geometry, USD drives, limits, and optional structure at runtime. The scene has four two-environment islands, so partial writes target environment 1 and prove environment 0 is preserved in the real PhysX state:

  • ordered: fixed base, MJWarp joint and body ordering, gains and limits loaded from USD.
  • floating: articulation root discovered on the base link below the spawned prim; configured dict gains and limits.
  • reordered: floating, with an explicit root path and a non-involutive body order that moves the root link.
  • tendon: fixed base, with a reversed joint and a spatial tendon.

Six composite nodes:

  • Initialization and ordering: names and orderings. USD gains and limits are checked in SI units, in both public and backend order, and configured overrides are checked against the solver.
  • Joint-state writes: writes reach PhysX in backend order and reads come back in public order. Forward kinematics refreshes after a joint write.
  • Joint and body properties: friction, limits and default clamping, and mass, COM and inertia partial writes, all read back from the PhysX view. Direct view mass/inertia writes become visible on the first read of a cold buffer and after the next update once the buffer is primed. The fixture takes the cold read on the identity-order floating island right after sim.reset(), so the check does not depend on which nodes ran first. The node restores the properties the drive node uses.
  • Drives and dynamics: the raw drive target and effort reach PhysX, the effort accelerates the joint ([Tests] Test PhysX joint effort application #7924), and the fixed root holds. Link and COM kinematics are checked against an analytic model. The Jacobian link-origin and COM contracts are checked on the fixed, reversed-joint and floating islands (the floating links get distinct COM offsets first, so link and COM Jacobians differ), together with mass-matrix symmetry, positive definiteness and the energy identity. The develop Jacobian and mass-matrix refresh loop after a manual joint write runs verbatim on the fixed and floating islands.
  • Floating roots: root pose writes are partial and invariant under body reordering, and the COM/link frames stay consistent. Local and global wrenches are compared, including at a position, with a lever-arm check. Multi-body wrenches are applied under body ordering, and the reordered island's velocities match the identity island's body by body. The partial/full composer and actuator reset assertions are kept verbatim.
  • Spatial tendons: distinct per-environment properties, then a partial environment-1 write, then distinct rows through unsorted int64 selectors ([1, 0]), each read back from the PhysX view.

Tests that need their own simulation context run above the composite section, because a new context would replace the composite stage:

  • Initialization failures: out-of-range default joint positions and velocities, and an invalid articulation root path, on the local fixture. Each matches its error message, so a different error cannot satisfy the test.
  • Shipped assets, assertions verbatim: the Shadow Hand native fixed-tendon target test ([Task Clean-up][Assets] Serve the Shadow Hand from one asset with native PhysX tendons #7161), Franka gravity-compensation static equilibrium, and Franka IK tracking.

Also in this PR:

  • test_articulation_kernels.py moves unchanged to unit/test_physx_articulation.py.
  • New source/isaaclab/test/envs/mdp/test_terminations.py: a unit test for joint_effort_out_of_limit. With two of three joints selected, it checks that the term terminates exactly the environments whose applied effort differs from the computed effort on any selected joint: one selected joint clipped terminates, both clipped terminates, none clipped does not, and only the unselected joint clipped does not. The term is backend independent, so this unit replaces the Nucleus Franka test_joint_effort_limits, which only tested all-clipped and none-clipped for every environment at once.
  • Accelerate and strengthen asset tests [1/13] #8134 owns the deprecated computed_torque/applied_torque aliases that test_joint_effort_limits exercised implicitly (test_deprecated_command_aliases_return_actuator_collection_buffers).

Disposition

Keepers are in this PR unless stated. "Mutation" means a one-line production change that turns the keeper red; each was checked red on the keeper and reverted.

Removed develop test Keeper Proof
test_live_manual_root_preserving_ordering_reorders_backend_reads_and_writes joint-state writes mutation: joint write without ordering; body reads without ordering
test_reversed_joint_dynamics_use_public_joint_basis drives and dynamics (tendon) mutation: all joint DOF signs +1
test_live_floating_root_writers_match_identity_after_body_reordering floating roots mutation: root COM writer reads public-order COM
test_live_direct_view_mass_inertia_writes_become_visible joint and body properties mutation: primed buffer never refreshes; cold buffer never refreshes (red in the full file and with the node alone)
test_branching_fixture_resolves_distinct_conventions initialization verbatim (same fixture)
test_initialization_floating_base, test_initialization_fixed_base initialization, drives (fixed root holds) mutation: is_fixed_base negated
test_initialization_floating_base_made_fixed_base, test_initialization_fixed_base_made_floating_base isaaclab/test/sim/test_articulation_fragments.py (develop) mutation: fix_articulation_root skipped; fixed joint left enabled
test_joint_pos_limits joint and body properties mutation: set_dof_limits skipped; default clamp disabled
test_external_force_on_single_body, test_external_force_on_single_body_at_position, test_external_force_on_multiple_bodies, test_external_force_on_multiple_bodies_at_position floating roots mutation: is_global negated; torques zeroed; wrench body reorder inverted (red on cpu and cuda:0)
test_loading_gains_from_usd, test_setting_gains_from_cfg initialization mutation: stiffness read from dampings; set_dof_stiffnesses skipped
test_setting_velocity_limit_writes_to_solver, test_setting_effort_limit_writes_to_solver initialization, drives mutation: max velocities / max forces / actuation forces not written
test_reset floating roots verbatim assertions
test_apply_joint_command drives mutation: position targets not submitted
test_body_root_state drives (analytic kinematics) mutation: COM→link velocity lever sign flipped
test_write_root_state floating roots mutation: COM→link pose offset sign flipped; partial root pose kernel writes row i
test_write_joint_state_data_consistency joint-state writes mutation: no pose invalidation after joint position write
test_write_joint_frictions_to_sim joint and body properties mutation: dynamic friction slot gets viscous
test_get_jacobians_link_origin_contract drives and dynamics mutation: link Jacobian returns the COM Jacobian; no link-origin shift when the offset is zero
test_dynamics_refresh_after_manual_joint_write drives and dynamics verbatim loop; mutation: Jacobian / mass matrix not invalidated by joint writes
test_spatial_tendons spatial tendons, including the unsorted int64 selectors mutation: damping slot receives limit stiffness; _resolve_env_ids sorts tensor selectors
test_out_of_range_default_joint_pos, test_out_of_range_default_joint_vel test_out_of_range_default_joint_state_raises mutation: position / velocity validation disabled
test_setting_articulation_root_prim_path, test_setting_invalid_articulation_root_prim_path test_setting_invalid_articulation_root_prim_path; explicit root path on the reordered island mutation: articulation_root_prim_path ignored
test_joint_effort_limits test_terminations.py; #8134 alias contract mutations: torch.isclose negation dropped; torch.any reduced with torch.all
test_fixed_tendon_position_target_writes_offset same test, moved verbatim
test_get_gravity_compensation_forces_static_equilibrium, test_franka_ik_tracking_accuracy same tests, moved verbatim

The raw articulation material round trip from the original PR is not added: it only reads back what it wrote through the PhysX view.

Devices and CI selection

  • The composite nodes run on every available device (cpu and cuda:0). The standalone tests keep their develop device scope: the Shadow Hand test runs on every device, the initialization-failure and Franka tests on CUDA.
  • @pytest.mark.isaacsim_ci is on the drives-and-dynamics node, which keeps the two marked develop tests test_get_jacobians_link_origin_contract and test_dynamics_refresh_after_manual_joint_write, and on the two Franka tests, as on develop.

Timing

Warm Warp cache, repository orchestrator (pytest tools), one process per file, second of two runs, RTX 5090. develop is 09b1d54; this branch is 0e24859.

Times are the per-file process wall times the orchestrator reports, including interpreter and Kit startup.

File develop This branch
test_articulation.py 45.8 s (76 tests) 11.6 s (19 tests)
test_articulation_kernels.py → unit/test_physx_articulation.py (moved) 4.5 s (7 tests) 4.4 s (7 tests)
source/isaaclab/test/envs/mdp/test_terminations.py (new) — 1.7 s (1 test)
Total 50.3 s 17.7 s

About 5 s of what remains in test_articulation.py is the three shipped-asset tests (Shadow Hand, Franka gravity compensation, Franka IK).

Found while writing this (not fixed, not pinned)

  • Stale body poses after a Jacobian read: after joint writes on several articulations, reading one articulation's Jacobian (get_jacobians) leaves the other articulations' body poses stale until the next step, although update_kinematics runs. The drives node reads body state before Jacobians to avoid this.
  • COM writes on GPU: a set_coms write reaches kinematic velocity updates only on the next step. The node steps once after its COM write.
  • Link-frame wrenches after a teleport on GPU: after root and joint writes with no Lab read in between, the next step applies link-frame wrenches with stale link transforms (applying identical raw forces to the same view gives a different response). Reading body_link_pose_w before the step avoids it; the multi-body wrench check does that.

Type of change

  • Test-suite redesign (no production change)

Release backport

  • Backport this pull request to the active release branch after it merges into develop

Checklist

Docker and GPU tests run on demand. Push the commits you want tested, then
comment run-ci on the pull request.

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with uv run isaaclab --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have validated the changed behavior with focused coverage and applied the test-audit criteria to any test changes
  • I have added a changelog fragment under source/<pkg>/changelog.d/ for every touched package (do not edit CHANGELOG.rst or bump package versions — CI handles that)
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

RigidObjectCollection.set_coms_index passed wp.transformf data to the
PhysX tensor API, which raises a KeyError. It also marked the lazily
filled body_com_pose_b cache as fresh after a partial write, so the
unselected entries read back as zeros when the cache had not been read
before. set_inertias_index flattened the (num_instances, num_bodies, 9)
inertias with the 2D reshape, which the backend rejects.

Pass the COM poses as float32, let the next read refresh the COM cache
from the view as RigidObject does, and reshape the inertias with the 3D
helper. A new test writes both properties to a non-sorted subset of
(env, body) cells and checks the PhysX view and the data buffers.
Move the mocked cross-backend asset interface tests into a contract package
with api, data, and write entry modules. An explicit capability table gives
every backend a visible row: unavailable backends and unsupported branches
collect as skips with their reason instead of silently dropping out. A
kitless usdrt/carb stub and an availability guard keep PhysX articulations
in the matrix, where they previously were skipped without notice.

Factory manager patches are scoped to one test and restored afterwards.
PhysX views apply TensorAPI writes so partial writers are checked against
unselected backend rows, Newton joins the fixed-tendon contract, the
deprecated command aliases are checked against the actuator collection, and
one enforced inventory classifies the public base-class surface.
Take over what the removed OVPhysX real-backend joint-state test checked, on
every backend: unsorted int64 environment and joint selectors on the fused
writer, the finite-difference baseline it restarts for the written joints,
skip_forward leaving body caches to the caller, and the deprecated combined
writer producing the same state as the public writers.
Check that joint_effort_out_of_limit terminates exactly the environments
whose applied effort differs from the computed effort on the selected
joints, including an environment that clips only unselected joints. The
term is backend independent; this replaces an all-or-nothing check that
built a Nucleus Franka scene in the PhysX articulation suite.
Add a module-scoped scene built from the local branching fixture with
two-environment islands: fixed with MJWarp ordering and USD drive gains
and limits, floating with configured gains and a root discovered below
the spawned prim, floating with an explicit root path and a root-moving
body order, and fixed with a reversed joint and a spatial tendon. Its
nodes cover structure and orderings, joint-state writes, joint and body
properties, drives, efforts and dynamics, and floating-root writes,
wrenches, and resets. Partial writes target environment 1 and prove that
environment 0 is preserved in the real PhysX state.

Remove the Nucleus-robot tests these nodes cover and move the PhysX
articulation kernel tests under unit/.
Add the spatial-tendon node and the Jacobian and mass-matrix refresh check to the composite scene, check initialization failures on the local fixture with their error messages, and keep the Shadow Hand fixed-tendon, Franka gravity-compensation, and Franka IK tests on their shipped assets. Remove the remaining Nucleus-robot articulation tests; the joint-effort termination term and the deprecated torque aliases now have their own unit and contract owners.
@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Low risk] Reorganizes and documents test files for articulation assets.

The PR appears safe to merge, though restoring the two lost coverage paths would strengthen the test replacement.

Findings

  1. P2 Runtime root conversion coverage lost ▶
  2. P2 CPU termination coverage removed ▶

Summary

The PR replaces many per-test robot scenes with one shared, two-environment PhysX scene and moves the unchanged kernel tests into unit/.

  • The replacement checks ordering, properties, dynamics, root writes, and wrenches against live PhysX state.
  • Two existing coverage paths are lost: runtime fix_root_link conversion and CPU joint-effort termination.

Reviews (1) · Last reviewed commit: "Run core PhysX articulation checks on on..."

Comment on lines +385 to +387
if fixed_base:
fixed_joint = UsdPhysics.FixedJoint.Define(stage, f"{robot_path}/fixed_root")
fixed_joint.GetBody1Rel().SetTargets([f"{robot_path}/base"])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Runtime root conversion coverage lost
The removed tests used spawn.fix_root_link to convert real assets between floating and fixed bases, then checked the resulting PhysX articulation. This replacement defines a fixed joint directly, so it cannot catch a regression between the spawner's conversion and PhysX initialization. Please retain a runtime test of that path.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@@ -877,85 +528,10 @@ def test_out_of_range_default_joint_vel(sim, device):


@pytest.mark.parametrize("num_articulations", [2])
@pytest.mark.parametrize("device", test_devices())
@pytest.mark.parametrize("device", test_devices(DeviceScope.CUDA))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 CPU termination coverage removed
This decorator drops the existing CPU check of joint_effort_out_of_limit. The new composite tests check effort limits and motion, but do not call the termination function, so a CPU-specific regression there would go unnoticed. Please keep the CPU parameter.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@AntoineRichard
AntoineRichard marked this pull request as draft September 29, 2026 12:54
Replace the static-method fixture helper with a module function, read
backend storage through bound getters instead of getattr on known names,
share one context for suppressing Newton model-change notifications, reuse
the timestamped-cache helpers in the joint-state case, complete return
annotations, and word comments by their current constraint.
Allocate per-joint expectations directly, map the islands and read the
Jacobians through explicit attributes, read the implicit-model class flag
directly, drop redundant contiguous copies, and document the kinematics
helpers with units and shapes.
Inline the one-line Warp-to-torch helper, read the implicit-model class
flag directly, and annotate the scene-owning tests and the fixture.
Run the index-resolution cases on OVPhysX, which implements the joint and
body helpers, and drop the capability every backend now shares. Make the
PhysX recording setters reject compact data instead of accepting it. Move
the tendon shape negatives into their own case so the Newton mask xfail
covers exactly the torch or warp oversized input it pins.
- Give the moving links of the floating island center-of-mass offsets
  before checking its Jacobians, so the link-origin shift is observable.
- Check the cold direct-view mass and inertia read on the reordered
  island, whose inertial buffers no other test reads, so the check does
  not depend on test order; restore the properties the drive test uses.
- Compare the multi-body wrench response of the reordered island with
  the identity-ordered island body by body, using the same actuators.
- Mark the drive and dynamics test for the Isaac Sim CI selection.
- Remove the single-joint articulation configs no remaining test uses.
Direct tensor-view mass and inertia writes must be visible on the first
read of a buffer that no update has primed. The composite fixture now
takes that read on the identity-order floating island right after
sim.reset(), so the check no longer depends on which tests ran first.
…antoiner/asset-tests-p12-physx-articulation-regressions

# Conflicts:
#	source/isaaclab_physx/test/assets/test_articulation.py
…set-tests-p12-physx-articulation-regressions
The spatial tendon node writes rows through unsorted int64 environment
ids, which the deleted spatial tendon test covered. The Shadow Hand
fixed tendon test runs on every available device again.
Read the friction, inertial, and wrench-response buffers through their
properties instead of getattr on attribute names.
…antoiner/asset-tests-p12-physx-articulation-regressions
Replace the getattr lookups of setters and data buffers in the spatial
tendon node with a helper that calls each setter, and share one loop
for the environment 1 and unsorted int64 partial writes.
@AntoineRichard AntoineRichard changed the title Accelerate and strengthen asset tests [11/24] Accelerate and strengthen asset tests [6/13] Sep 29, 2026
@StafaH

StafaH commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

Closing because the combined PR #7282 has merged. This split PR is superseded by #7282 and is no longer needed.

@StafaH StafaH closed this Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants