Skip to content

Commit 82c5ce7

Browse files
authored
[Feature] Update to new sapien 3 linux package (#1194)
* update * update based on sapien 42f295073878600fcd898ffe7ab351eac433e41e based on haosulab/SAPIEN@42f2950 * updated based on sapien 72ae940cdfc81cb4ee65b62339a28a86a7406cc5, expose collision stack size haosulab/SAPIEN@72ae940 * Update sapien_env.py * updated based on sapien f3ca0417c501e1a70ebba08c156bbdb6019175ef, fix link lin/angular velocity orders haosulab/SAPIEN@f3ca041
1 parent 9e0efc3 commit 82c5ce7

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

mani_skill/envs/sapien_env.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,16 @@ def __init__(
264264
common.dict_merge(merged_gpu_sim_config, sim_config)
265265
self.sim_config = dacite.from_dict(data_class=SimConfig, data=merged_gpu_sim_config, config=dacite.Config(strict=True))
266266
"""the final sim config after merging user overrides with the environment default"""
267-
physx.set_gpu_memory_config(**self.sim_config.gpu_memory_config.dict())
267+
gpu_mem_config = self.sim_config.gpu_memory_config.dict()
268+
269+
# NOTE (stao): there isn't a easy way to check of collision_stack_size is supported for the installed sapien3 version
270+
# to get around that we just try and except. To be removed once mac/windows platforms can upgrade to latest sapien versions
271+
try:
272+
physx.set_gpu_memory_config(**gpu_mem_config)
273+
except TypeError:
274+
gpu_mem_config.pop("collision_stack_size")
275+
physx.set_gpu_memory_config(**gpu_mem_config)
276+
268277
sapien.render.set_log_level(os.getenv("MS_RENDERER_LOG_LEVEL", "warn"))
269278

270279
# Set simulation and control frequency

mani_skill/utils/building/actor_builder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def build_physx_component(self, link_parent=None):
160160
component.cmass_local_pose = self._cmass_local_pose
161161
component.inertia = self._inertia
162162

163+
component.name = self.name
163164
return component
164165

165166
def build_dynamic(self, name):

mani_skill/utils/structs/base.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,6 @@ def angular_damping(self, arg1: float) -> None:
206206
@property
207207
def angular_velocity(self) -> torch.Tensor:
208208
if self.scene.gpu_sim_enabled:
209-
# NOTE (stao): Currently physx has a bug that sapien inherits where link bodies on the GPU put linear/angular velocities in the wrong order...
210-
if isinstance(self._objs[0], physx.PhysxArticulationLinkComponent):
211-
return self._body_data[self._body_data_index, 7:10]
212209
return self._body_data[self._body_data_index, 10:13]
213210
else:
214211
return torch.tensor(
@@ -263,9 +260,8 @@ def linear_damping(self, arg1: float) -> None:
263260
@property
264261
def linear_velocity(self) -> torch.Tensor:
265262
if self.scene.gpu_sim_enabled:
266-
# NOTE (stao): Currently physx has a bug that sapien inherits where link bodies on the GPU put linear/angular velocities in the wrong order...
267-
if isinstance(self._objs[0], physx.PhysxArticulationLinkComponent):
268-
return self._body_data[self._body_data_index, 10:13]
263+
# NOTE (stao): SAPIEN version 3.0.0b1 gpu sim has a bug inherited from physx where linear/angular velocities are in the wrong order
264+
# for link entities, namely 7:10 was angular velocity and 10:13 was linear velocity. SAPIEN 3.0.0 and above fixes this
269265
return self._body_data[self._body_data_index, 7:10]
270266
else:
271267
return torch.from_numpy(self._bodies[0].linear_velocity[None, :])
@@ -358,9 +354,6 @@ def set_locked_motion_axes(self, axes: Array) -> None:
358354
@property
359355
def angular_velocity(self) -> torch.Tensor:
360356
if self.scene.gpu_sim_enabled:
361-
# NOTE (stao): Currently physx has a bug that sapien inherits where link bodies on the GPU put linear/angular velocities in the wrong order...
362-
if isinstance(self._objs[0], physx.PhysxArticulationLinkComponent):
363-
return self._body_data[self._body_data_index, 7:10]
364357
return self._body_data[self._body_data_index, 10:13]
365358
else:
366359
return torch.from_numpy(self._bodies[0].angular_velocity[None, :])
@@ -429,9 +422,6 @@ def is_sleeping(self):
429422
@property
430423
def linear_velocity(self) -> torch.Tensor:
431424
if self.scene.gpu_sim_enabled:
432-
# NOTE (stao): Currently physx has a bug that sapien inherits where link bodies on the GPU put linear/angular velocities in the wrong order...
433-
if isinstance(self._objs[0], physx.PhysxArticulationLinkComponent):
434-
return self._body_data[self._body_data_index, 10:13]
435425
return self._body_data[self._body_data_index, 7:10]
436426
else:
437427
return torch.tensor(

mani_skill/utils/structs/types.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ class GPUMemoryConfig:
2727
) # 262144 is SAPIEN default but most tasks work with 2**25
2828
found_lost_aggregate_pairs_capacity: int = 2**10
2929
total_aggregate_pairs_capacity: int = 2**10
30+
collision_stack_size: int = 64 * 64 * 1024 # this is the same default as SAPIEN
31+
"""Increase this if you get 'Collision stack overflow detected'"""
3032

3133
def dict(self):
3234
return {k: v for k, v in asdict(self).items()}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def get_dependencies():
4747
"pynvml", # gpu monitoring
4848
"tyro>=0.8.5", # nice, typed, command line arg parser
4949
"huggingface_hub", # we use HF to version control some assets/datasets more easily
50-
"sapien>=3.0.0.b1;platform_system=='Linux'",
50+
"sapien>=3.0.0;platform_system=='Linux'",
5151
"sapien>=3.0.0.b1;platform_system=='Windows'",
5252
]
5353
# NOTE (stao): until sapien is uploaded to pypi with mac support, users need to install manually below as so

0 commit comments

Comments
 (0)