-
Notifications
You must be signed in to change notification settings - Fork 3k
Replaces Isaac Sim SimulationManager with IsaacLab SimulationManager #4475
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
base: develop
Are you sure you want to change the base?
Changes from 113 commits
6fd9082
dcc4737
fcf6c1a
f54ae43
2f9afad
c1413d4
4652ac6
a10e419
a1a714d
d347aef
9929597
263054d
53a8ddb
590ff75
8e5153f
17d6936
836d0c6
62361ac
113ac86
b33eb9a
c7f6b23
b406521
dc62696
083a2c3
366f338
8c5e7c1
618e2f1
bd98dda
56cf54d
cbbccdf
33576d4
381d489
b1b5350
3a085d1
a75f85d
a5a9648
98d3388
e4eee14
4aab3c5
9de9fea
b5d1e38
3145c52
82f10f4
9104778
8527b3b
6834e09
9faf081
dad21af
67faf0a
2bc8c1e
ac1619b
9bfada7
6a7d78d
28f1348
582d281
1b3f82a
e8afe79
f504226
34a0770
bf10837
b77a28c
865502d
8e5d080
bddd0c2
8da331f
a253344
58d031b
2928529
dcf8d10
25a313e
bcee357
51d68c0
c81a2d9
a2f6548
1d8d50a
832db86
fae3e0c
3b6fb8a
e77de12
f1afe76
b0a2949
567c10d
2a42985
68bb030
eed1305
11625d7
d94635d
ceeaf5e
c7b8437
682ddfd
5b97b78
ffcf770
32f4165
a4bd7cb
2d6d8ad
11a9c25
db9e25d
0672828
a120b91
235a9e8
283669f
a530d7e
62e0a98
031f171
f248424
f9e29e3
17ce717
3d6f1a4
e1e1302
d7d952e
8c9ae3a
d4c99f1
d3e4f73
83d7c8b
1f297d1
8d277e9
3707bb0
17e62fc
53cb6fa
c89b550
930985f
68a9a6c
7d13fb9
0cb95dd
4c238f5
a82e8c7
fadd8e7
13920ef
6ac6ed4
8e24e52
5315495
6be6ac8
dc20d8e
4b1d3ae
1a11880
07c0573
81c91d1
1538f48
aaa3d8b
8a11590
deb84dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ keywords = ["experience", "app", "usd"] | |
| "isaacsim.core.api" = {} | ||
| "isaacsim.core.cloner" = {} | ||
| "isaacsim.core.nodes" = {} | ||
| "isaacsim.core.simulation_manager" = {} | ||
| # "isaacsim.core.simulation_manager" = {} # Replaced by isaaclab.sim.simulation_manager | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be removed directly? |
||
| "isaacsim.core.throttling" = {} | ||
| "isaacsim.core.utils" = {} | ||
| "isaacsim.core.version" = {} | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we remove the isaacsim_4_5 apps or do we plan on supporting those still? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ keywords = ["experience", "app", "usd"] | |
| "isaacsim.core.api" = {} | ||
| "isaacsim.core.cloner" = {} | ||
| "isaacsim.core.nodes" = {} | ||
| "isaacsim.core.simulation_manager" = {} | ||
| # "isaacsim.core.simulation_manager" = {} # Replaced by isaaclab.sim.simulation_manager | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can just be removed? |
||
| "isaacsim.core.throttling" = {} | ||
| "isaacsim.core.utils" = {} | ||
| "isaacsim.core.version" = {} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ | |
|
|
||
| import omni.kit.app | ||
| import omni.timeline | ||
| from isaacsim.core.simulation_manager import IsaacEvents, SimulationManager | ||
| from isaaclab.sim import IsaacEvents, SimulationManager | ||
|
|
||
| import isaaclab.sim as sim_utils | ||
| from isaaclab.sim.utils.stage import get_current_stage | ||
|
|
@@ -308,15 +308,18 @@ def _initialize_callback(self, event): | |
| called whenever the simulator "plays" from a "stop" state. | ||
| """ | ||
| if not self._is_initialized: | ||
| # obtain simulation related information | ||
| self._backend = SimulationManager.get_backend() | ||
| self._device = SimulationManager.get_physics_sim_device() | ||
| # initialize the asset | ||
| try: | ||
| # Obtain Simulation Context | ||
| sim = sim_utils.SimulationContext.instance() | ||
| if sim is None: | ||
| raise RuntimeError("Simulation Context is not initialized!") | ||
| # Obtain device and backend | ||
| self._device = sim.device | ||
| # initialize the asset | ||
| self._initialize_impl() | ||
| except Exception as e: | ||
| if builtins.ISAACLAB_CALLBACK_EXCEPTION is None: | ||
| builtins.ISAACLAB_CALLBACK_EXCEPTION = e | ||
| if builtins.ISAACLAB_CALLBACK_EXCEPTION is None: # type: ignore | ||
| builtins.ISAACLAB_CALLBACK_EXCEPTION = e # type: ignore | ||
|
Comment on lines
320
to
+322
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we use builtins over a class variable in the simulation context? |
||
| # set flag | ||
| self._is_initialized = True | ||
|
|
||
|
|
@@ -327,15 +330,16 @@ def _invalidate_initialize_callback(self, event): | |
| self._debug_vis_handle.unsubscribe() | ||
| self._debug_vis_handle = None | ||
|
|
||
| def _on_prim_deletion(self, prim_path: str) -> None: | ||
| def _on_prim_deletion(self, event) -> None: | ||
| """Invalidates and deletes the callbacks when the prim is deleted. | ||
|
|
||
| Args: | ||
| prim_path: The path to the prim that is being deleted. | ||
| event: The prim deletion event containing the prim path in payload. | ||
|
|
||
| Note: | ||
| This function is called when the prim is deleted. | ||
| """ | ||
| prim_path = event.payload["prim_path"] | ||
| if prim_path == "/": | ||
| self._clear_callbacks() | ||
| return | ||
|
|
@@ -345,8 +349,12 @@ def _on_prim_deletion(self, prim_path: str) -> None: | |
| if result: | ||
| self._clear_callbacks() | ||
|
|
||
| def _clear_callbacks(self) -> None: | ||
| """Clears the callbacks.""" | ||
| def _clear_callbacks(self, event: Any = None) -> None: | ||
| """Clears the callbacks. | ||
|
|
||
| Args: | ||
| event: Optional event that triggered the callback (unused but required for event handlers). | ||
| """ | ||
| if self._prim_deletion_callback_id: | ||
| SimulationManager.deregister_callback(self._prim_deletion_callback_id) | ||
|
||
| self._prim_deletion_callback_id = None | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ | |
|
|
||
| from __future__ import annotations | ||
|
|
||
| import builtins | ||
| import gymnasium as gym | ||
| import inspect | ||
| import logging | ||
|
|
@@ -150,17 +149,16 @@ def __init__(self, cfg: DirectMARLEnvCfg, render_mode: str | None = None, **kwar | |
| # play the simulator to activate physics handles | ||
| # note: this activates the physics simulation view that exposes TensorAPIs | ||
| # note: when started in extension mode, first call sim.reset_async() and then initialize the managers | ||
| if builtins.ISAAC_LAUNCHED_FROM_TERMINAL is False: | ||
| print("[INFO]: Starting the simulation. This may take a few seconds. Please wait...") | ||
| with Timer("[INFO]: Time taken for simulation start", "simulation_start"): | ||
| # since the reset can trigger callbacks which use the stage, | ||
| # we need to set the stage context here | ||
| with use_stage(self.sim.get_initial_stage()): | ||
| self.sim.reset() | ||
| # update scene to pre populate data buffers for assets and sensors. | ||
| # this is needed for the observation manager to get valid tensors for initialization. | ||
| # this shouldn't cause an issue since later on, users do a reset over all the environments so the lazy buffers would be reset. | ||
| self.scene.update(dt=self.physics_dt) | ||
| print("[INFO]: Starting the simulation. This may take a few seconds. Please wait...") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally this should use the logger.info |
||
| with Timer("[INFO]: Time taken for simulation start", "simulation_start"): | ||
| # since the reset can trigger callbacks which use the stage, | ||
| # we need to set the stage context here | ||
| with use_stage(self.sim.get_initial_stage()): | ||
| self.sim.reset() | ||
| # update scene to pre populate data buffers for assets and sensors. | ||
| # this is needed for the observation manager to get valid tensors for initialization. | ||
| # this shouldn't cause an issue since later on, users do a reset over all the environments so the lazy buffers would be reset. | ||
| self.scene.update(dt=self.physics_dt) | ||
|
|
||
| # check if debug visualization is has been implemented by the environment | ||
| source_code = inspect.getsource(self._set_debug_vis_impl) | ||
|
|
@@ -549,7 +547,6 @@ def close(self): | |
| self.sim.stop() | ||
| self.sim.clear() | ||
|
|
||
| self.sim.clear_all_callbacks() | ||
| self.sim.clear_instance() | ||
|
|
||
| # destroy the window | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ | |
|
|
||
| from __future__ import annotations | ||
|
|
||
| import builtins | ||
| import gymnasium as gym | ||
| import inspect | ||
| import logging | ||
|
|
@@ -21,7 +20,7 @@ | |
|
|
||
| import omni.kit.app | ||
| import omni.physx | ||
| from isaacsim.core.simulation_manager import SimulationManager | ||
| from isaaclab.sim.simulation_manager import SimulationManager | ||
|
|
||
| from isaaclab.managers import EventManager | ||
| from isaaclab.scene import InteractiveScene | ||
|
|
@@ -157,17 +156,16 @@ def __init__(self, cfg: DirectRLEnvCfg, render_mode: str | None = None, **kwargs | |
| # play the simulator to activate physics handles | ||
| # note: this activates the physics simulation view that exposes TensorAPIs | ||
| # note: when started in extension mode, first call sim.reset_async() and then initialize the managers | ||
| if builtins.ISAAC_LAUNCHED_FROM_TERMINAL is False: | ||
| print("[INFO]: Starting the simulation. This may take a few seconds. Please wait...") | ||
| with Timer("[INFO]: Time taken for simulation start", "simulation_start"): | ||
| # since the reset can trigger callbacks which use the stage, | ||
| # we need to set the stage context here | ||
| with use_stage(self.sim.get_initial_stage()): | ||
| self.sim.reset() | ||
| # update scene to pre populate data buffers for assets and sensors. | ||
| # this is needed for the observation manager to get valid tensors for initialization. | ||
| # this shouldn't cause an issue since later on, users do a reset over all the environments so the lazy buffers would be reset. | ||
| self.scene.update(dt=self.physics_dt) | ||
| print("[INFO]: Starting the simulation. This may take a few seconds. Please wait...") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally this should use logger.info |
||
| with Timer("[INFO]: Time taken for simulation start", "simulation_start"): | ||
| # since the reset can trigger callbacks which use the stage, | ||
| # we need to set the stage context here | ||
| with use_stage(self.sim.get_initial_stage()): | ||
| self.sim.reset() | ||
| # update scene to pre populate data buffers for assets and sensors. | ||
| # this is needed for the observation manager to get valid tensors for initialization. | ||
| # this shouldn't cause an issue since later on, users do a reset over all the environments so the lazy buffers would be reset. | ||
| self.scene.update(dt=self.physics_dt) | ||
|
|
||
| # check if debug visualization is has been implemented by the environment | ||
| source_code = inspect.getsource(self._set_debug_vis_impl) | ||
|
|
@@ -518,7 +516,6 @@ def close(self): | |
| self.sim.stop() | ||
| self.sim.clear() | ||
|
|
||
| self.sim.clear_all_callbacks() | ||
| self.sim.clear_instance() | ||
|
|
||
| # destroy the window | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,15 +3,14 @@ | |
| # | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| import builtins | ||
| import logging | ||
| import torch | ||
| import warnings | ||
| from collections.abc import Sequence | ||
| from typing import Any | ||
|
|
||
| import omni.physx | ||
| from isaacsim.core.simulation_manager import SimulationManager | ||
| from isaaclab.sim.simulation_manager import SimulationManager | ||
|
|
||
| from isaaclab.managers import ActionManager, EventManager, ObservationManager, RecorderManager | ||
| from isaaclab.scene import InteractiveScene | ||
|
|
@@ -101,11 +100,7 @@ def __init__(self, cfg: ManagerBasedEnvCfg): | |
| # since it gets confused with Isaac Sim's SimulationContext class | ||
| self.sim: SimulationContext = SimulationContext(self.cfg.sim) | ||
| else: | ||
| # simulation context should only be created before the environment | ||
| # when in extension mode | ||
| if not builtins.ISAAC_LAUNCHED_FROM_TERMINAL: | ||
| raise RuntimeError("Simulation context already exists. Cannot create a new one.") | ||
| self.sim: SimulationContext = SimulationContext.instance() | ||
| raise RuntimeError("Simulation context already exists. Cannot create a new one.") | ||
|
|
||
| # make sure torch is running on the correct device | ||
| if "cuda" in self.device: | ||
|
|
@@ -162,19 +157,18 @@ def __init__(self, cfg: ManagerBasedEnvCfg): | |
| # play the simulator to activate physics handles | ||
| # note: this activates the physics simulation view that exposes TensorAPIs | ||
| # note: when started in extension mode, first call sim.reset_async() and then initialize the managers | ||
| if builtins.ISAAC_LAUNCHED_FROM_TERMINAL is False: | ||
| print("[INFO]: Starting the simulation. This may take a few seconds. Please wait...") | ||
| with Timer("[INFO]: Time taken for simulation start", "simulation_start"): | ||
| # since the reset can trigger callbacks which use the stage, | ||
| # we need to set the stage context here | ||
| with use_stage(self.sim.get_initial_stage()): | ||
| self.sim.reset() | ||
| # update scene to pre populate data buffers for assets and sensors. | ||
| # this is needed for the observation manager to get valid tensors for initialization. | ||
| # this shouldn't cause an issue since later on, users do a reset over all the environments so the lazy buffers would be reset. | ||
| self.scene.update(dt=self.physics_dt) | ||
| # add timeline event to load managers | ||
| self.load_managers() | ||
| print("[INFO]: Starting the simulation. This may take a few seconds. Please wait...") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the logger |
||
| with Timer("[INFO]: Time taken for simulation start", "simulation_start"): | ||
| # since the reset can trigger callbacks which use the stage, | ||
| # we need to set the stage context here | ||
| with use_stage(self.sim.get_initial_stage()): | ||
| self.sim.reset() | ||
| # update scene to pre populate data buffers for assets and sensors. | ||
| # this is needed for the observation manager to get valid tensors for initialization. | ||
| # this shouldn't cause an issue since later on, users do a reset over all the environments so the lazy buffers would be reset. | ||
| self.scene.update(dt=self.physics_dt) | ||
| # add timeline event to load managers | ||
| self.load_managers() | ||
|
|
||
| # extend UI elements | ||
| # we need to do this here after all the managers are initialized | ||
|
|
@@ -536,7 +530,6 @@ def close(self): | |
| self.sim.stop() | ||
| self.sim.clear() | ||
|
|
||
| self.sim.clear_all_callbacks() | ||
| self.sim.clear_instance() | ||
|
|
||
| # destroy the window | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove the isaacsim_4_5 apps or do we plan on supporting those still?