Unverified Commit 5c021834 authored by Mayank Mittal's avatar Mayank Mittal Committed by GitHub

Removes duplicate enabling of faulthandler (#603)

Sometimes the simulation app got stuck when trying to interrupt the
process from the terminal. Removing the call to faulthandler resolved
this issue (I think). In Isaac Sim 4.0, the fault handler is enabled
inside the SimulationApp directly so we don't need to do it anymore.

## Type of change

- Bug fix (non-breaking change which fixes an issue)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have run all the tests with `./isaaclab.sh --test` and they pass
- [ ] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there
parent 691b9e81
...@@ -44,7 +44,6 @@ To upload images to a PR -- simply drag and drop an image while in edit mode and ...@@ -44,7 +44,6 @@ To upload images to a PR -- simply drag and drop an image while in edit mode and
- [ ] I have made corresponding changes to the documentation - [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings - [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have run all the tests with `./isaaclab.sh --test` and they pass
- [ ] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [ ] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file
- [ ] I have added my name to the `CONTRIBUTORS.md` or my name already exists there - [ ] I have added my name to the `CONTRIBUTORS.md` or my name already exists there
......
...@@ -14,7 +14,6 @@ fault occurs. The launched :class:`omni.isaac.kit.SimulationApp` instance is acc ...@@ -14,7 +14,6 @@ fault occurs. The launched :class:`omni.isaac.kit.SimulationApp` instance is acc
import argparse import argparse
import contextlib import contextlib
import faulthandler
import os import os
import re import re
import signal import signal
...@@ -69,9 +68,6 @@ class AppLauncher: ...@@ -69,9 +68,6 @@ class AppLauncher:
.. _argparse.Namespace: https://docs.python.org/3/library/argparse.html?highlight=namespace#argparse.Namespace .. _argparse.Namespace: https://docs.python.org/3/library/argparse.html?highlight=namespace#argparse.Namespace
.. _SimulationApp: https://docs.omniverse.nvidia.com/py/isaacsim/source/extensions/omni.isaac.kit/docs/index.html .. _SimulationApp: https://docs.omniverse.nvidia.com/py/isaacsim/source/extensions/omni.isaac.kit/docs/index.html
""" """
# Enable call-stack on crash
faulthandler.enable()
# We allow users to pass either a dict or an argparse.Namespace into # We allow users to pass either a dict or an argparse.Namespace into
# __init__, anticipating that these will be all of the argparse arguments # __init__, anticipating that these will be all of the argparse arguments
# used by the calling script. Those which we appended via add_app_launcher_args # used by the calling script. Those which we appended via add_app_launcher_args
......
...@@ -148,6 +148,10 @@ class UniformPoseCommand(CommandTerm): ...@@ -148,6 +148,10 @@ class UniformPoseCommand(CommandTerm):
self.body_pose_visualizer.set_visibility(False) self.body_pose_visualizer.set_visibility(False)
def _debug_vis_callback(self, event): def _debug_vis_callback(self, event):
# check if robot is initialized
# note: this is needed in-case the robot is de-initialized. we can't access the data
if not self.robot.is_initialized:
return
# update the markers # update the markers
# -- goal pose # -- goal pose
self.goal_pose_visualizer.visualize(self.pose_command_w[:, :3], self.pose_command_w[:, 3:]) self.goal_pose_visualizer.visualize(self.pose_command_w[:, :3], self.pose_command_w[:, 3:])
......
...@@ -168,6 +168,10 @@ class UniformVelocityCommand(CommandTerm): ...@@ -168,6 +168,10 @@ class UniformVelocityCommand(CommandTerm):
self.base_vel_visualizer.set_visibility(False) self.base_vel_visualizer.set_visibility(False)
def _debug_vis_callback(self, event): def _debug_vis_callback(self, event):
# check if robot is initialized
# note: this is needed in-case the robot is de-initialized. we can't access the data
if not self.robot.is_initialized:
return
# get marker location # get marker location
# -- base state # -- base state
base_pos_w = self.robot.data.root_pos_w.clone() base_pos_w = self.robot.data.root_pos_w.clone()
......
...@@ -140,12 +140,14 @@ class SimulationContext(_SimulationContext): ...@@ -140,12 +140,14 @@ class SimulationContext(_SimulationContext):
self._local_gui = carb_settings_iface.get("/app/window/enabled") self._local_gui = carb_settings_iface.get("/app/window/enabled")
# read flag for whether livestreaming GUI is enabled # read flag for whether livestreaming GUI is enabled
self._livestream_gui = carb_settings_iface.get("/app/livestream/enabled") self._livestream_gui = carb_settings_iface.get("/app/livestream/enabled")
# read flag for whether the Isaac Lab viewport capture pipeline will be used, # read flag for whether the Isaac Lab viewport capture pipeline will be used,
# casting None to False if the flag doesn't exist # casting None to False if the flag doesn't exist
# this flag is set from the AppLauncher class # this flag is set from the AppLauncher class
self._offscreen_render = bool(carb_settings_iface.get("/isaaclab/render/offscreen")) self._offscreen_render = bool(carb_settings_iface.get("/isaaclab/render/offscreen"))
# flag for whether any GUI will be rendered (local, livestreamed or viewport) # flag for whether any GUI will be rendered (local, livestreamed or viewport)
self._has_gui = self._local_gui or self._livestream_gui self._has_gui = self._local_gui or self._livestream_gui
# store the default render mode # store the default render mode
if not self._has_gui and not self._offscreen_render: if not self._has_gui and not self._offscreen_render:
# set default render mode # set default render mode
...@@ -204,6 +206,7 @@ class SimulationContext(_SimulationContext): ...@@ -204,6 +206,7 @@ class SimulationContext(_SimulationContext):
) )
else: else:
self._app_control_on_stop_handle = None self._app_control_on_stop_handle = None
# flatten out the simulation dictionary # flatten out the simulation dictionary
sim_params = self.cfg.to_dict() sim_params = self.cfg.to_dict()
if sim_params is not None: if sim_params is not None:
...@@ -588,8 +591,12 @@ class SimulationContext(_SimulationContext): ...@@ -588,8 +591,12 @@ class SimulationContext(_SimulationContext):
) )
while self.app.is_running(): while self.app.is_running():
self.render() self.render()
# Note: For the following code:
# The method is an exact copy of the implementation in the `omni.isaac.kit.SimulationApp` class.
# We need to remove this method once the SimulationApp class becomes a singleton.
# make sure that any replicator workflows finish rendering/writing # make sure that any replicator workflows finish rendering/writing
if not builtins.ISAAC_LAUNCHED_FROM_TERMINAL:
try: try:
import omni.replicator.core as rep import omni.replicator.core as rep
...@@ -598,20 +605,42 @@ class SimulationContext(_SimulationContext): ...@@ -598,20 +605,42 @@ class SimulationContext(_SimulationContext):
rep.orchestrator.stop() rep.orchestrator.stop()
if rep_status != rep.orchestrator.Status.STOPPED: if rep_status != rep.orchestrator.Status.STOPPED:
rep.orchestrator.wait_until_complete() rep.orchestrator.wait_until_complete()
# Disable capture on play to avoid replicator engaging on any new timeline events
rep.orchestrator.set_capture_on_play(False)
except Exception: except Exception:
pass pass
# clear the instance and all callbacks # clear the instance and all callbacks
# note: clearing callbacks is important to prevent memory leaks # note: clearing callbacks is important to prevent memory leaks
self.clear_all_callbacks() self.clear_all_callbacks()
# workaround for exit issues, clean the stage first: # workaround for exit issues, clean the stage first:
if omni.usd.get_context().can_close_stage(): if omni.usd.get_context().can_close_stage():
omni.usd.get_context().close_stage() omni.usd.get_context().close_stage()
# print logging information # print logging information
self.app.print_and_log("Simulation is stopped. Shutting down the app.") self.app.print_and_log("Simulation is stopped. Shutting down the app...")
# shutdown the simulator
self.app.shutdown() # Cleanup any running tracy instances so data is not lost
# disabled on linux to avoid a crash try:
carb.get_framework().unload_all_plugins() profiler_tracy = carb.profiler.acquire_profiler_interface(plugin_name="carb.profiler-tracy.plugin")
if profiler_tracy:
profiler_tracy.set_capture_mask(0)
profiler_tracy.end(0)
profiler_tracy.shutdown()
except RuntimeError:
# Tracy plugin was not loaded, so profiler never started - skip checks.
pass
# Disable logging before shutdown to keep the log clean
# Warnings at this point don't matter as the python process is about to be terminated
logging = carb.logging.acquire_logging()
logging.set_level_threshold(carb.logging.LEVEL_ERROR)
# App shutdown is disabled to prevent crashes on shutdown. Terminating carb is faster
# self._app.shutdown()
self._framework.unload_all_plugins()
@contextmanager @contextmanager
......
...@@ -122,6 +122,10 @@ class PreTrainedPolicyAction(ActionTerm): ...@@ -122,6 +122,10 @@ class PreTrainedPolicyAction(ActionTerm):
self.base_vel_visualizer.set_visibility(False) self.base_vel_visualizer.set_visibility(False)
def _debug_vis_callback(self, event): def _debug_vis_callback(self, event):
# check if robot is initialized
# note: this is needed in-case the robot is de-initialized. we can't access the data
if not self.robot.is_initialized:
return
# get marker location # get marker location
# -- base state # -- base state
base_pos_w = self.robot.data.root_pos_w.clone() base_pos_w = self.robot.data.root_pos_w.clone()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment