Skip to content

Fixes collision filtering logic on CPU #2553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/isaaclab/config/extension.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

# Note: Semantic Versioning is used: https://semver.org/
version = "0.40.4"
version = "0.40.5"

# Description
title = "Isaac Lab framework for Robot Learning"
Expand Down
10 changes: 10 additions & 0 deletions source/isaaclab/docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changelog
---------

0.40.5 (2025-05-22)
~~~~~~~~~~~~~~~~~~~

Fixed
^^^^^

* Fixed collision filtering logic for CPU simulation. The automatic collision filtering feature
currently has limitations for CPU simulation. Collision filtering needs to be manually enabled when using CPU simulation.


0.40.4 (2025-06-03)
~~~~~~~~~~~~~~~~~~~

Expand Down
8 changes: 5 additions & 3 deletions source/isaaclab/isaaclab/scene/interactive_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ def __init__(self, cfg: InteractiveSceneCfg):

# since env_ids is only applicable when replicating physics, we have to fallback to the previous method
# to filter collisions if replicate_physics is not enabled
if not self.cfg.replicate_physics and self.cfg.filter_collisions:
# additionally, env_ids is only supported in GPU simulation
if (not self.cfg.replicate_physics and self.cfg.filter_collisions) or self.device == "cpu":
self.filter_collisions(self._global_prim_paths)

def clone_environments(self, copy_from_source: bool = False):
Expand Down Expand Up @@ -204,9 +205,10 @@ def clone_environments(self, copy_from_source: bool = False):

# since env_ids is only applicable when replicating physics, we have to fallback to the previous method
# to filter collisions if replicate_physics is not enabled
if not self.cfg.replicate_physics and self.cfg.filter_collisions:
# additionally, env_ids is only supported in GPU simulation
if (not self.cfg.replicate_physics and self.cfg.filter_collisions) or self.device == "cpu":
omni.log.warn(
"Collision filtering can only be automatically enabled when replicate_physics=True."
"Collision filtering can only be automatically enabled when replicate_physics=True and GPU simulation."
" Please call scene.filter_collisions(global_prim_paths) to filter collisions across environments."
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def _setup_scene(self):
self._terrain = self.cfg.terrain.class_type(self.cfg.terrain)
# clone and replicate
self.scene.clone_environments(copy_from_source=False)
# we need to explicitly filter collisions for CPU simulation
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm is it possible to put this inside environments cloning (as a flag to filter collisions)? It gets strange in the code to have this changing frequently 😓

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ya we should be able to do that, we can add a few more arguments to clone_environments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm I think this might be a breaking change if we put it inside clone_environments. we can only call filter collision once in the cloner, so if users already have that call in their scripts, then doing it this way will break their scripts.

if self.device == "cpu":
self.scene.filter_collisions(global_prim_paths=[self.cfg.terrain.prim_path])
# add lights
light_cfg = sim_utils.DomeLightCfg(intensity=2000.0, color=(0.75, 0.75, 0.75))
light_cfg.func("/World/Light", light_cfg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ def _setup_scene(self):
spawn_ground_plane(prim_path="/World/ground", cfg=GroundPlaneCfg())
# clone and replicate
self.scene.clone_environments(copy_from_source=False)
# we need to explicitly filter collisions for CPU simulation
if self.device == "cpu":
self.scene.filter_collisions(global_prim_paths=[])
# add articulation to scene
self.scene.articulations["robot"] = self.robot
# add lights
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ def _setup_scene(self):

# clone and replicate
self.scene.clone_environments(copy_from_source=False)
if self.device == "cpu":
# we need to explicitly filter collisions for CPU simulation
self.scene.filter_collisions(global_prim_paths=[])

# add articulation and sensors to scene
self.scene.articulations["cartpole"] = self._cartpole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ def _setup_scene(self):
spawn_ground_plane(prim_path="/World/ground", cfg=GroundPlaneCfg())
# clone and replicate
self.scene.clone_environments(copy_from_source=False)
# we need to explicitly filter collisions for CPU simulation
if self.device == "cpu":
self.scene.filter_collisions(global_prim_paths=[])
# add articulation to scene
self.scene.articulations["cartpole"] = self.cartpole
# add lights
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ def _setup_scene(self):
self._large_gear_asset = Articulation(self.cfg_task.large_gear_cfg)

self.scene.clone_environments(copy_from_source=False)
if self.device == "cpu":
# we need to explicitly filter collisions for CPU simulation
self.scene.filter_collisions()

self.scene.articulations["robot"] = self._robot
self.scene.articulations["fixed_asset"] = self._fixed_asset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ def _setup_scene(self):

# clone and replicate
self.scene.clone_environments(copy_from_source=False)
# we need to explicitly filter collisions for CPU simulation
if self.device == "cpu":
self.scene.filter_collisions(global_prim_paths=[self.cfg.terrain.prim_path])

# add lights
light_cfg = sim_utils.DomeLightCfg(intensity=2000.0, color=(0.75, 0.75, 0.75))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def _setup_scene(self):
)
# clone and replicate
self.scene.clone_environments(copy_from_source=False)
# we need to explicitly filter collisions for CPU simulation
if self.device == "cpu":
self.scene.filter_collisions(global_prim_paths=["/World/ground"])

# add articulation to scene
self.scene.articulations["robot"] = self.robot
# add lights
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ def _setup_scene(self):
self.terrain = self.cfg.terrain.class_type(self.cfg.terrain)
# clone and replicate
self.scene.clone_environments(copy_from_source=False)
# we need to explicitly filter collisions for CPU simulation
if self.device == "cpu":
self.scene.filter_collisions(global_prim_paths=[self.cfg.terrain.prim_path])
# add articulation to scene
self.scene.articulations["robot"] = self.robot
# add lights
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ def _setup_scene(self):
self._terrain = self.cfg.terrain.class_type(self.cfg.terrain)
# clone and replicate
self.scene.clone_environments(copy_from_source=False)
# we need to explicitly filter collisions for CPU simulation
if self.device == "cpu":
self.scene.filter_collisions(global_prim_paths=[self.cfg.terrain.prim_path])
# add lights
light_cfg = sim_utils.DomeLightCfg(intensity=2000.0, color=(0.75, 0.75, 0.75))
light_cfg.func("/World/Light", light_cfg)
Expand Down
3 changes: 3 additions & 0 deletions tools/template/templates/tasks/direct_multi-agent/env
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class {{ task.classname }}Env(DirectMARLEnv):
spawn_ground_plane(prim_path="/World/ground", cfg=GroundPlaneCfg())
# clone and replicate
self.scene.clone_environments(copy_from_source=False)
# we need to explicitly filter collisions for CPU simulation
if self.device == "cpu":
self.scene.filter_collisions(global_prim_paths=[])
# add articulation to scene
self.scene.articulations["robot"] = self.robot
# add lights
Expand Down
3 changes: 3 additions & 0 deletions tools/template/templates/tasks/direct_single-agent/env
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class {{ task.classname }}Env(DirectRLEnv):
spawn_ground_plane(prim_path="/World/ground", cfg=GroundPlaneCfg())
# clone and replicate
self.scene.clone_environments(copy_from_source=False)
# we need to explicitly filter collisions for CPU simulation
if self.device == "cpu":
self.scene.filter_collisions(global_prim_paths=[])
# add articulation to scene
self.scene.articulations["robot"] = self.robot
# add lights
Expand Down