Skip to content

Commit 88e04d2

Browse files
authored
Add the Newton Franka rope SoftMimicGen workflow
1 parent a0900ad commit 88e04d2

14 files changed

Lines changed: 904 additions & 19 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#usda 1.0
2+
# Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
(
5+
defaultPrim = "World"
6+
)
7+
8+
# Keep the shared simulation topology, round visual mesh, and material.
9+
# Newton uses the simulation tetrahedra directly; the PhysX collision mesh is redundant.
10+
def Xform "World" (
11+
prepend references = @Rope.usd@
12+
)
13+
{
14+
over "collision_mesh" (
15+
active = false
16+
)
17+
{
18+
}
19+
}

‎autodata_examples/envs/isaac_lab_arena/franka_rope/embodiment.py‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from isaaclab_arena.embodiments.common.arm_mode import ArmMode
2020
from isaaclab_arena.embodiments.franka.franka import FrankaIKEmbodiment
2121
from isaaclab_arena.utils.cameras import ArenaCameraCfg
22+
from isaaclab_arena.utils.physics_backend import PhysicsBackend
2223
from isaaclab_arena.utils.pose import Pose
2324
from isaaclab_physx.renderers import IsaacRtxRendererCfg, IsaacRtxRendererGlobalSettingsCfg
2425

@@ -159,6 +160,35 @@ def __init__(
159160
self.event_config = FrankaRopeEventsCfg()
160161
self.reward_config = None
161162

163+
def _configure_physics_backend(self, backend: PhysicsBackend) -> None:
164+
"""Apply Newton gravity compensation and mesh contact settings to the Franka."""
165+
if backend is PhysicsBackend.NEWTON:
166+
from isaaclab_newton.renderers import NewtonWarpRendererCfg
167+
from isaaclab_newton.sim.schemas import (
168+
MujocoRigidBodyCfg,
169+
NewtonMaterialPropertiesCfg,
170+
NewtonSDFCollisionPropertiesCfg,
171+
)
172+
173+
from .newton_cfg import spawn_rope_franka_newton
174+
175+
spawn = self.scene_config.robot.spawn
176+
# Match the shared high-PD Franka's PhysX-only disable_gravity setting.
177+
spawn.rigid_props = MujocoRigidBodyCfg(gravcomp=1.0)
178+
spawn.make_uninstanceable = True
179+
spawn.func = spawn_rope_franka_newton
180+
# Full-surface soft contacts require SDFs for the mesh colliders.
181+
spawn.collision_props = NewtonSDFCollisionPropertiesCfg(sdf_max_resolution=64)
182+
spawn.physics_material = NewtonMaterialPropertiesCfg(
183+
static_friction=3.0, dynamic_friction=3.0, restitution=0.0
184+
)
185+
# Maintain pose tracking under the deformable solver's contact feedback.
186+
self.scene_config.robot.actuators["panda_shoulder"].stiffness = 800.0
187+
self.scene_config.robot.actuators["panda_forearm"].stiffness = 800.0
188+
# Read rigid poses and deformable triangles directly from Newton state.
189+
for camera_name in self.camera_config.camera_names():
190+
getattr(self.camera_config, camera_name).renderer_cfg = NewtonWarpRendererCfg()
191+
162192

163193
@register_retargeter
164194
class FrankaRopeKeyboardRetargeter(RetargetterBase):

‎autodata_examples/envs/isaac_lab_arena/franka_rope/environment.py‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from isaaclab_arena.environments.arena_environment_factory import ArenaEnvironmentCfg, ArenaEnvironmentFactory
1313
from isaaclab_arena.utils.pose import Pose
1414

15-
from .rope_asset import FrankaRopeAsset
15+
from .rope_asset import FrankaRopeAsset, rope_newton_spawn_cfg
1616
from .task import FrankaRopeTask
1717

1818
if TYPE_CHECKING:
@@ -31,13 +31,35 @@ class FrankaRopeArenaEnvironmentCfg(ArenaEnvironmentCfg):
3131

3232

3333
def _configure_franka_rope_env(env_cfg: Any) -> Any:
34-
"""Apply rope timing and asset settings for PhysX."""
34+
"""Apply rope timing and asset/solver settings for Arena's selected backend."""
35+
36+
from isaaclab_newton.physics import NewtonCfg
3537

3638
env_cfg.decimation = 5
3739
env_cfg.sim.dt = 0.01
3840
env_cfg.sim.render_interval = 2
3941
env_cfg.num_rerenders_on_reset = 1
40-
env_cfg.scene.replicate_physics = False
42+
if isinstance(env_cfg.sim.physics, NewtonCfg):
43+
from isaaclab_newton.sim.schemas import MujocoCollisionCfg
44+
45+
from .newton_cfg import rope_newton_physics_cfg, spawn_rope_table_newton
46+
47+
env_cfg.sim.physics = rope_newton_physics_cfg()
48+
# Refresh Kit once per control step; the solver still advances at 1 ms.
49+
env_cfg.sim.render_interval = env_cfg.decimation
50+
env_cfg.scene.object.spawn = rope_newton_spawn_cfg()
51+
# A discontinuous half-mesh reset can invert the connecting tetrahedra.
52+
# Blend the same sampled poses through the middle half of the rope.
53+
env_cfg.events.reset_object_position.params["transition_length"] = 0.4
54+
env_cfg.scene.replicate_physics = True
55+
env_cfg.scene.table.spawn.make_uninstanceable = True
56+
env_cfg.scene.table.spawn.func = spawn_rope_table_newton
57+
# A firm, critically damped table contact in MJWarp. Priority keeps the
58+
# table response from being softened by the gripper's default material.
59+
# These MuJoCo parameters do not change VBD's rope contact properties.
60+
env_cfg.scene.table.spawn.collision_props = MujocoCollisionCfg(priority=1, solref=(0.004, 1.0))
61+
else:
62+
env_cfg.scene.replicate_physics = False
4163
env_cfg.teleop_devices = DevicesCfg(
4264
devices={
4365
"keyboard": Se3KeyboardCfg(

‎autodata_examples/envs/isaac_lab_arena/franka_rope/mdp/events.py‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ def reset_rope_nodal_state(
7878
pose_range: dict[str, tuple[float, float]],
7979
partial_pose_range: dict[str, tuple[float, float]],
8080
asset_cfg: SceneEntityCfg = SceneEntityCfg("object"),
81+
transition_length: float | None = None,
8182
) -> None:
8283
"""Reset and randomize the rope, including a transform of one rope half.
8384
@@ -87,6 +88,8 @@ def reset_rope_nodal_state(
8788
pose_range: Translation [m] and rotation [rad] ranges applied to all nodes.
8889
partial_pose_range: Additional translation [m] and rotation [rad] ranges applied to one rope half.
8990
asset_cfg: Deformable rope entity.
91+
transition_length: Length [m] over which to blend the half-rope transform.
92+
None preserves the original piecewise reset used by PhysX.
9093
"""
9194

9295
rope: DeformableObject = env.scene[asset_cfg.name]
@@ -101,6 +104,24 @@ def reset_rope_nodal_state(
101104
)
102105
node_ids = torch.tensor(_ROPE_PARTIAL_NODE_IDS, device=rope.device)
103106
position, quaternion = _sample_pose_delta(partial_pose_range, len(env_ids), rope.device)
104-
nodal_state[..., node_ids, :3] = rope.transform_nodal_pos(nodal_state[..., node_ids, :3], position, quaternion)
107+
if transition_length is None:
108+
nodal_state[..., node_ids, :3] = rope.transform_nodal_pos(nodal_state[..., node_ids, :3], position, quaternion)
109+
else:
110+
assert transition_length > 0.0
111+
nodes = nodal_state[..., :3]
112+
center = nodes.mean(dim=1, keepdim=True)
113+
half_center = nodes[:, node_ids].mean(dim=1, keepdim=True)
114+
axis = torch.nn.functional.normalize(half_center - center, dim=-1)
115+
distance = ((nodes - center) * axis).sum(dim=-1, keepdim=True)
116+
fraction = (distance / transition_length + 0.5).clamp(0.0, 1.0)
117+
# A C2-continuous transition avoids tearing/inverting the tetrahedra at
118+
# the boundary of the two halves. End sections retain their rigid poses.
119+
weight = fraction**3 * (10.0 - 15.0 * fraction + 6.0 * fraction**2)
120+
transformed = (
121+
math_utils.quat_apply(quaternion[:, None, :].expand(-1, nodes.shape[1], -1), nodes - half_center)
122+
+ half_center
123+
+ position[:, None, :]
124+
)
125+
nodal_state[..., :3] = nodes + weight * (transformed - nodes)
105126

106127
rope.write_nodal_state_to_sim_index(nodal_state, env_ids=env_ids)
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
"""Newton rigid--deformable physics for the shared Franka rope task."""
5+
6+
from __future__ import annotations
7+
8+
from typing import TYPE_CHECKING
9+
10+
from isaaclab.sim.spawners.from_files import UsdFileCfg, spawn_from_usd
11+
from isaaclab.sim.utils import clone
12+
from isaaclab_contrib.coupling import CouplerEntryCfg, CouplerProxyCfg, CouplerProxyMappingCfg
13+
from isaaclab_newton.physics import (
14+
MJWarpSolverCfg,
15+
NewtonCfg,
16+
NewtonCollisionPipelineCfg,
17+
NewtonSoftContactCfg,
18+
VBDSolverCfg,
19+
)
20+
21+
if TYPE_CHECKING:
22+
from pxr import Usd
23+
24+
25+
@clone
26+
def spawn_rope_franka_newton(
27+
prim_path: str,
28+
cfg: UsdFileCfg,
29+
translation: tuple[float, float, float] | None = None,
30+
orientation: tuple[float, float, float, float] | None = None,
31+
**kwargs,
32+
) -> Usd.Prim:
33+
"""Use analytic finger colliders for stable volumetric rope contacts.
34+
35+
The boxes occupy the original collision meshes' bounds. Visual meshes and
36+
articulation joints remain those of the shared Franka.
37+
38+
Args:
39+
prim_path: Prim path or pattern at which to spawn the robot.
40+
cfg: Robot USD spawner configuration.
41+
translation: Translation relative to the parent [m].
42+
orientation: Rotation quaternion in XYZW order.
43+
**kwargs: Additional arguments forwarded to the USD spawner.
44+
45+
Returns:
46+
The spawned robot prim.
47+
"""
48+
from pxr import Gf, UsdGeom
49+
50+
prim = spawn_from_usd(prim_path, cfg, translation, orientation, **kwargs)
51+
for finger in ("panda_leftfinger", "panda_rightfinger"):
52+
collider = prim.GetStage().GetPrimAtPath(f"{prim.GetPath()}/{finger}/collisions/collisions")
53+
assert collider.IsValid() and collider.GetTypeName() == "Mesh", "Expected the legacy Franka finger collider"
54+
points = UsdGeom.Mesh(collider).GetPointsAttr().Get()
55+
lower = Gf.Vec3d(*(min(point[axis] for point in points) for axis in range(3)))
56+
upper = Gf.Vec3d(*(max(point[axis] for point in points) for axis in range(3)))
57+
collider.SetTypeName("Cube")
58+
cube = UsdGeom.Cube(collider)
59+
cube.CreateSizeAttr(1.0)
60+
cube.AddTranslateOp(opSuffix="rope_contact_center").Set((lower + upper) * 0.5)
61+
cube.AddScaleOp(opSuffix="rope_contact_size").Set(upper - lower)
62+
return prim
63+
64+
65+
@clone
66+
def spawn_rope_table_newton(
67+
prim_path: str,
68+
cfg: UsdFileCfg,
69+
translation: tuple[float, float, float] | None = None,
70+
orientation: tuple[float, float, float, float] | None = None,
71+
**kwargs,
72+
) -> Usd.Prim:
73+
"""Use an analytic box for the Seattle table's existing unit-cube collider.
74+
75+
Args:
76+
prim_path: Prim path or pattern at which to spawn the table.
77+
cfg: Table USD spawner configuration.
78+
translation: Translation relative to the parent [m].
79+
orientation: Rotation quaternion in XYZW order.
80+
**kwargs: Additional arguments forwarded to the USD spawner.
81+
82+
Returns:
83+
The spawned table prim.
84+
"""
85+
from pxr import UsdGeom
86+
87+
prim = spawn_from_usd(prim_path, cfg, translation, orientation, **kwargs)
88+
collider = prim.GetStage().GetPrimAtPath(f"{prim.GetPath()}/Collisions/Cube")
89+
assert collider.IsValid() and collider.GetTypeName() == "Mesh", "Expected the Seattle table's cube mesh collider"
90+
collider.SetTypeName("Cube")
91+
UsdGeom.Cube(collider).CreateSizeAttr(1.0)
92+
return prim
93+
94+
95+
def rope_newton_physics_cfg() -> NewtonCfg:
96+
"""Couple the Franka's rigid dynamics to the rope's volumetric VBD solve."""
97+
return NewtonCfg(
98+
solver_cfg=CouplerProxyCfg(
99+
class_type="autodata_examples.envs.isaac_lab_arena.franka_rope.newton_visuals:NewtonRopeManager",
100+
entries=[
101+
CouplerEntryCfg(
102+
name="rigid",
103+
solver_cfg=MJWarpSolverCfg(cone="elliptic", ls_iterations=20, integrator="implicitfast"),
104+
bodies=[r"/World/envs/env_[^/]+/Robot"],
105+
include_static_shapes=True,
106+
),
107+
CouplerEntryCfg(
108+
name="soft",
109+
solver_cfg=VBDSolverCfg(
110+
iterations=10,
111+
rigid_body_particle_contact_buffer_size=4096,
112+
particle_enable_self_contact=True,
113+
particle_self_contact_radius=0.002,
114+
particle_self_contact_margin=0.003,
115+
),
116+
all_particles=True,
117+
),
118+
],
119+
proxies=[
120+
CouplerProxyMappingCfg(
121+
source="rigid",
122+
destination="soft",
123+
bodies=[
124+
r"/World/envs/env_[^/]+/Robot/.*panda_hand",
125+
r"/World/envs/env_[^/]+/Robot/.*panda_(left|right)finger",
126+
],
127+
mode="lagged",
128+
collide_interval=1,
129+
collision_pipeline=NewtonCollisionPipelineCfg(enable_rigid_soft_full_surface_contact=True),
130+
),
131+
],
132+
iterations=1,
133+
),
134+
soft_contact_cfg=NewtonSoftContactCfg(
135+
# Resolve contacts around the narrow rope, with enough friction to carry it.
136+
soft_contact_ke=1.0e5,
137+
soft_contact_kd=10.0,
138+
soft_contact_mu=10.0,
139+
),
140+
num_substeps=10,
141+
)

0 commit comments

Comments
 (0)