Unverified Commit 07fc74d2 authored by Mayank Mittal's avatar Mayank Mittal Committed by GitHub

Adds try-catch in all the scripts for safe app closing (#185)

# Description

Propogates the try-except-finally paradigm from the unit tests to all
the scripts. This ensures a cleaner exit of the script and allows a
better traceback print.

```python
import traceback

import carb

if __name__ == "__main__":
    try:
        # Run the main function
        main()
    except Exception as err:
        carb.log_error(err)
        carb.log_error(traceback.format_exc())
        raise
    finally:
        # close sim app
        simulation_app.close()
```

## Type of change

- New feature (non-breaking change which adds functionality)
- This change requires a documentation update

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./orbit.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 updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
parent 8ba18efa
...@@ -23,7 +23,9 @@ simulation_app = SimulationApp({"headless": False}) ...@@ -23,7 +23,9 @@ simulation_app = SimulationApp({"headless": False})
"""Rest everything follows.""" """Rest everything follows."""
import ctypes import ctypes
import traceback
import carb
from omni.isaac.core.simulation_context import SimulationContext from omni.isaac.core.simulation_context import SimulationContext
from omni.isaac.orbit.devices import Se3Keyboard from omni.isaac.orbit.devices import Se3Keyboard
...@@ -85,7 +87,13 @@ def main(): ...@@ -85,7 +87,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# Runs the main function try:
# Run the main function
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -29,6 +29,10 @@ simulation_app = app_launcher.app ...@@ -29,6 +29,10 @@ simulation_app = app_launcher.app
"""Rest everything follows.""" """Rest everything follows."""
import traceback
import carb
import omni.isaac.orbit.sim as sim_utils import omni.isaac.orbit.sim as sim_utils
from omni.isaac.orbit.assets import AssetBaseCfg from omni.isaac.orbit.assets import AssetBaseCfg
from omni.isaac.orbit.assets.config.anymal import ANYMAL_C_CFG from omni.isaac.orbit.assets.config.anymal import ANYMAL_C_CFG
...@@ -154,7 +158,13 @@ def main(): ...@@ -154,7 +158,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
try:
# Run the main function # Run the main function
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -35,7 +35,9 @@ simulation_app = SimulationApp(config) ...@@ -35,7 +35,9 @@ simulation_app = SimulationApp(config)
import torch import torch
import traceback
import carb
import omni.isaac.core.utils.prims as prim_utils import omni.isaac.core.utils.prims as prim_utils
from omni.isaac.cloner import GridCloner from omni.isaac.cloner import GridCloner
from omni.isaac.core.simulation_context import SimulationContext from omni.isaac.core.simulation_context import SimulationContext
...@@ -175,7 +177,13 @@ def main(): ...@@ -175,7 +177,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
try:
# Run the main function # Run the main function
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -42,7 +42,9 @@ simulation_app = SimulationApp(config) ...@@ -42,7 +42,9 @@ simulation_app = SimulationApp(config)
import numpy as np import numpy as np
import torch import torch
import traceback
import carb
import omni.isaac.core.utils.prims as prim_utils import omni.isaac.core.utils.prims as prim_utils
from omni.isaac.cloner import GridCloner from omni.isaac.cloner import GridCloner
from omni.isaac.core.objects import DynamicSphere from omni.isaac.core.objects import DynamicSphere
...@@ -182,7 +184,13 @@ def main(): ...@@ -182,7 +184,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# Runs the main function try:
# Run the main function
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -63,7 +63,9 @@ simulation_app = SimulationApp(config) ...@@ -63,7 +63,9 @@ simulation_app = SimulationApp(config)
import numpy as np import numpy as np
import traceback
import carb
import omni.isaac.core.utils.prims as prim_utils import omni.isaac.core.utils.prims as prim_utils
import omni.kit.commands import omni.kit.commands
from omni.isaac.cloner import GridCloner from omni.isaac.cloner import GridCloner
...@@ -200,7 +202,13 @@ def main(): ...@@ -200,7 +202,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# Runs the main function try:
# Run the main function
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -41,6 +41,9 @@ simulation_app = app_launcher.app ...@@ -41,6 +41,9 @@ simulation_app = app_launcher.app
import torch import torch
import traceback
import carb
import omni.isaac.orbit.sim as sim_utils import omni.isaac.orbit.sim as sim_utils
from omni.isaac.orbit.assets import Articulation from omni.isaac.orbit.assets import Articulation
...@@ -140,7 +143,13 @@ def main(): ...@@ -140,7 +143,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# Run the main function try:
# run the main execution
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -36,7 +36,9 @@ import numpy as np ...@@ -36,7 +36,9 @@ import numpy as np
import os import os
import random import random
import torch import torch
import traceback
import carb
import omni.isaac.core.utils.prims as prim_utils import omni.isaac.core.utils.prims as prim_utils
import omni.isaac.debug_draw._debug_draw as omni_debug_draw import omni.isaac.debug_draw._debug_draw as omni_debug_draw
import omni.replicator.core as rep import omni.replicator.core as rep
...@@ -226,7 +228,13 @@ def main(): ...@@ -226,7 +228,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# Runs the main function try:
# run the main execution
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -33,7 +33,9 @@ simulation_app = app_launcher.app ...@@ -33,7 +33,9 @@ simulation_app = app_launcher.app
import torch import torch
import traceback
import carb
import omni.isaac.core.utils.prims as prim_utils import omni.isaac.core.utils.prims as prim_utils
from omni.isaac.cloner import GridCloner from omni.isaac.cloner import GridCloner
...@@ -147,7 +149,13 @@ def main(): ...@@ -147,7 +149,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# Run the main function try:
# run the main execution
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -25,6 +25,9 @@ simulation_app = app_launcher.app ...@@ -25,6 +25,9 @@ simulation_app = app_launcher.app
"""Rest everything follows.""" """Rest everything follows."""
import traceback
import carb
import omni.isaac.orbit.sim as sim_utils import omni.isaac.orbit.sim as sim_utils
from omni.isaac.orbit.sim import SimulationContext from omni.isaac.orbit.sim import SimulationContext
...@@ -61,7 +64,13 @@ def main(): ...@@ -61,7 +64,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# Run empty stage try:
# run the main execution
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -32,7 +32,9 @@ simulation_app = app_launcher.app ...@@ -32,7 +32,9 @@ simulation_app = app_launcher.app
"""Rest everything follows.""" """Rest everything follows."""
import torch import torch
import traceback
import carb
import omni.isaac.core.utils.prims as prim_utils import omni.isaac.core.utils.prims as prim_utils
from omni.isaac.cloner import GridCloner from omni.isaac.cloner import GridCloner
from omni.isaac.core.simulation_context import SimulationContext from omni.isaac.core.simulation_context import SimulationContext
...@@ -224,7 +226,13 @@ def main(): ...@@ -224,7 +226,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# Run IK example with Manipulator try:
# run the main execution
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -28,6 +28,9 @@ simulation_app = app_launcher.app ...@@ -28,6 +28,9 @@ simulation_app = app_launcher.app
"""Rest everything follows.""" """Rest everything follows."""
import torch import torch
import traceback
import carb
import omni.isaac.orbit.sim as sim_utils import omni.isaac.orbit.sim as sim_utils
from omni.isaac.orbit.markers import VisualizationMarkers, VisualizationMarkersCfg from omni.isaac.orbit.markers import VisualizationMarkers, VisualizationMarkersCfg
...@@ -136,7 +139,13 @@ def main(): ...@@ -136,7 +139,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# Run empty stage try:
# run the main execution
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -33,6 +33,9 @@ simulation_app = app_launcher.app ...@@ -33,6 +33,9 @@ simulation_app = app_launcher.app
"""Rest everything follows.""" """Rest everything follows."""
import traceback
import carb
import omni.isaac.orbit.sim as sim_utils import omni.isaac.orbit.sim as sim_utils
from omni.isaac.orbit.assets import Articulation from omni.isaac.orbit.assets import Articulation
...@@ -118,7 +121,13 @@ def main(): ...@@ -118,7 +121,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# Run the main function try:
# run the main execution
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -38,6 +38,9 @@ simulation_app = app_launcher.app ...@@ -38,6 +38,9 @@ simulation_app = app_launcher.app
import torch import torch
import traceback
import carb
import omni.isaac.orbit.sim as sim_utils import omni.isaac.orbit.sim as sim_utils
from omni.isaac.orbit.assets import Articulation from omni.isaac.orbit.assets import Articulation
...@@ -156,7 +159,13 @@ def main(): ...@@ -156,7 +159,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# Run the main function try:
# run the main execution
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -35,7 +35,9 @@ simulation_app = app_launcher.app ...@@ -35,7 +35,9 @@ simulation_app = app_launcher.app
import torch import torch
import traceback
import carb
import omni.isaac.core.utils.prims as prim_utils import omni.isaac.core.utils.prims as prim_utils
from omni.isaac.cloner import GridCloner from omni.isaac.cloner import GridCloner
from omni.isaac.core.simulation_context import SimulationContext from omni.isaac.core.simulation_context import SimulationContext
...@@ -245,7 +247,13 @@ def main(): ...@@ -245,7 +247,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# Run IK example with Manipulator try:
# run the main execution
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -28,6 +28,9 @@ app_launcher = AppLauncher(headless=args_cli.headless) ...@@ -28,6 +28,9 @@ app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app simulation_app = app_launcher.app
"""Rest everything follows.""" """Rest everything follows."""
import traceback
import carb
import omni.isaac.orbit.sim as sim_utils import omni.isaac.orbit.sim as sim_utils
from omni.isaac.orbit.assets import AssetBaseCfg from omni.isaac.orbit.assets import AssetBaseCfg
...@@ -147,7 +150,13 @@ def main(): ...@@ -147,7 +150,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# Run the main function try:
# run the main execution
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -28,6 +28,9 @@ simulation_app = app_launcher.app ...@@ -28,6 +28,9 @@ simulation_app = app_launcher.app
"""Rest everything follows.""" """Rest everything follows."""
import torch import torch
import traceback
import carb
import omni.isaac.orbit.sim as sim_utils import omni.isaac.orbit.sim as sim_utils
from omni.isaac.orbit.assets import RigidObject, RigidObjectCfg from omni.isaac.orbit.assets import RigidObject, RigidObjectCfg
...@@ -116,7 +119,13 @@ def main(): ...@@ -116,7 +119,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# Run the main function try:
# run the main execution
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -31,6 +31,9 @@ simulation_app = app_launcher.app ...@@ -31,6 +31,9 @@ simulation_app = app_launcher.app
import gym import gym
import torch import torch
import traceback
import carb
import omni.isaac.contrib_envs # noqa: F401 import omni.isaac.contrib_envs # noqa: F401
import omni.isaac.orbit_envs # noqa: F401 import omni.isaac.orbit_envs # noqa: F401
...@@ -58,8 +61,16 @@ def main(): ...@@ -58,8 +61,16 @@ def main():
# close the simulator # close the simulator
env.close() env.close()
simulation_app.close()
if __name__ == "__main__": if __name__ == "__main__":
try:
# run the main execution
main() main()
except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close()
...@@ -31,9 +31,11 @@ simulation_app = app_launcher.app ...@@ -31,9 +31,11 @@ simulation_app = app_launcher.app
import gym import gym
import torch import torch
import traceback
from enum import Enum from enum import Enum
from typing import Sequence from typing import Sequence
import carb
import warp as wp import warp as wp
from omni.isaac.orbit.utils.timer import Timer from omni.isaac.orbit.utils.timer import Timer
...@@ -278,7 +280,13 @@ def main(): ...@@ -278,7 +280,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# run main function try:
# run the main execution
main() main()
# close simulation except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -33,6 +33,7 @@ simulation_app = app_launcher.app ...@@ -33,6 +33,7 @@ simulation_app = app_launcher.app
import gym import gym
import torch import torch
import traceback
import carb import carb
...@@ -114,8 +115,16 @@ def main(): ...@@ -114,8 +115,16 @@ def main():
# close the simulator # close the simulator
env.close() env.close()
simulation_app.close()
if __name__ == "__main__": if __name__ == "__main__":
try:
# run the main execution
main() main()
except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close()
...@@ -30,6 +30,9 @@ simulation_app = app_launcher.app ...@@ -30,6 +30,9 @@ simulation_app = app_launcher.app
import gym import gym
import torch import torch
import traceback
import carb
import omni.isaac.contrib_envs # noqa: F401 import omni.isaac.contrib_envs # noqa: F401
import omni.isaac.orbit_envs # noqa: F401 import omni.isaac.orbit_envs # noqa: F401
...@@ -57,8 +60,16 @@ def main(): ...@@ -57,8 +60,16 @@ def main():
# close the simulator # close the simulator
env.close() env.close()
simulation_app.close()
if __name__ == "__main__": if __name__ == "__main__":
try:
# run the main execution
main() main()
except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close()
...@@ -38,7 +38,9 @@ simulation_app = app_launcher.app ...@@ -38,7 +38,9 @@ simulation_app = app_launcher.app
import gym import gym
import math import math
import os import os
import traceback
import carb
from rl_games.common import env_configurations, vecenv from rl_games.common import env_configurations, vecenv
from rl_games.common.player import BasePlayer from rl_games.common.player import BasePlayer
from rl_games.torch_runner import Runner from rl_games.torch_runner import Runner
...@@ -138,8 +140,16 @@ def main(): ...@@ -138,8 +140,16 @@ def main():
# close the simulator # close the simulator
env.close() env.close()
simulation_app.close()
if __name__ == "__main__": if __name__ == "__main__":
try:
# run the main execution
main() main()
except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close()
...@@ -43,8 +43,10 @@ simulation_app = app_launcher.app ...@@ -43,8 +43,10 @@ simulation_app = app_launcher.app
import gym import gym
import math import math
import os import os
import traceback
from datetime import datetime from datetime import datetime
import carb
from rl_games.common import env_configurations, vecenv from rl_games.common import env_configurations, vecenv
from rl_games.common.algo_observer import IsaacAlgoObserver from rl_games.common.algo_observer import IsaacAlgoObserver
from rl_games.torch_runner import Runner from rl_games.torch_runner import Runner
...@@ -131,8 +133,16 @@ def main(): ...@@ -131,8 +133,16 @@ def main():
# close the simulator # close the simulator
env.close() env.close()
simulation_app.close()
if __name__ == "__main__": if __name__ == "__main__":
try:
# run the main execution
main() main()
except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close()
...@@ -36,6 +36,9 @@ import contextlib ...@@ -36,6 +36,9 @@ import contextlib
import gym import gym
import os import os
import torch import torch
import traceback
import carb
from omni.isaac.orbit.devices import Se3Keyboard, Se3SpaceMouse from omni.isaac.orbit.devices import Se3Keyboard, Se3SpaceMouse
from omni.isaac.orbit.utils.io import dump_pickle, dump_yaml from omni.isaac.orbit.utils.io import dump_pickle, dump_yaml
...@@ -158,8 +161,16 @@ def main(): ...@@ -158,8 +161,16 @@ def main():
# close the simulator # close the simulator
collector_interface.close() collector_interface.close()
env.close() env.close()
simulation_app.close()
if __name__ == "__main__": if __name__ == "__main__":
try:
# run the main execution
main() main()
except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close()
...@@ -31,7 +31,9 @@ simulation_app = app_launcher.app ...@@ -31,7 +31,9 @@ simulation_app = app_launcher.app
import gym import gym
import torch import torch
import traceback
import carb
import robomimic # noqa: F401 import robomimic # noqa: F401
import robomimic.utils.file_utils as FileUtils import robomimic.utils.file_utils as FileUtils
import robomimic.utils.torch_utils as TorchUtils import robomimic.utils.torch_utils as TorchUtils
...@@ -79,8 +81,16 @@ def main(): ...@@ -79,8 +81,16 @@ def main():
# close the simulator # close the simulator
env.close() env.close()
simulation_app.close()
if __name__ == "__main__": if __name__ == "__main__":
try:
# run the main execution
main() main()
except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close()
...@@ -32,7 +32,9 @@ simulation_app = app_launcher.app ...@@ -32,7 +32,9 @@ simulation_app = app_launcher.app
import gym import gym
import os import os
import traceback
import carb
from rsl_rl.runners import OnPolicyRunner from rsl_rl.runners import OnPolicyRunner
import omni.isaac.contrib_envs # noqa: F401 import omni.isaac.contrib_envs # noqa: F401
...@@ -101,8 +103,16 @@ def main(): ...@@ -101,8 +103,16 @@ def main():
# close the simulator # close the simulator
env.close() env.close()
simulation_app.close()
if __name__ == "__main__": if __name__ == "__main__":
try:
# run the main execution
main() main()
except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close()
...@@ -44,8 +44,10 @@ simulation_app = app_launcher.app ...@@ -44,8 +44,10 @@ simulation_app = app_launcher.app
import gym import gym
import os import os
import torch import torch
import traceback
from datetime import datetime from datetime import datetime
import carb
from rsl_rl.runners import OnPolicyRunner from rsl_rl.runners import OnPolicyRunner
from omni.isaac.orbit.utils.dict import print_dict from omni.isaac.orbit.utils.dict import print_dict
...@@ -129,8 +131,16 @@ def main(): ...@@ -129,8 +131,16 @@ def main():
# close the simulator # close the simulator
env.close() env.close()
simulation_app.close()
if __name__ == "__main__": if __name__ == "__main__":
try:
# run the main execution
main() main()
except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close()
...@@ -32,7 +32,9 @@ simulation_app = app_launcher.app ...@@ -32,7 +32,9 @@ simulation_app = app_launcher.app
import gym import gym
import traceback
import carb
from stable_baselines3 import PPO from stable_baselines3 import PPO
from stable_baselines3.common.vec_env import VecNormalize from stable_baselines3.common.vec_env import VecNormalize
...@@ -88,8 +90,16 @@ def main(): ...@@ -88,8 +90,16 @@ def main():
# close the simulator # close the simulator
env.close() env.close()
simulation_app.close()
if __name__ == "__main__": if __name__ == "__main__":
try:
# run the main execution
main() main()
except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close()
...@@ -43,8 +43,10 @@ simulation_app = app_launcher.app ...@@ -43,8 +43,10 @@ simulation_app = app_launcher.app
import gym import gym
import os import os
import traceback
from datetime import datetime from datetime import datetime
import carb
from stable_baselines3 import PPO from stable_baselines3 import PPO
from stable_baselines3.common.callbacks import CheckpointCallback from stable_baselines3.common.callbacks import CheckpointCallback
from stable_baselines3.common.logger import configure from stable_baselines3.common.logger import configure
...@@ -125,8 +127,16 @@ def main(): ...@@ -125,8 +127,16 @@ def main():
# close the simulator # close the simulator
env.close() env.close()
simulation_app.close()
if __name__ == "__main__": if __name__ == "__main__":
try:
# run the main execution
main() main()
except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close()
...@@ -37,7 +37,9 @@ simulation_app = app_launcher.app ...@@ -37,7 +37,9 @@ simulation_app = app_launcher.app
import gym import gym
import traceback
import carb
from skrl.agents.torch.ppo import PPO, PPO_DEFAULT_CONFIG from skrl.agents.torch.ppo import PPO, PPO_DEFAULT_CONFIG
from skrl.utils.model_instantiators import deterministic_model, gaussian_model, shared_model from skrl.utils.model_instantiators import deterministic_model, gaussian_model, shared_model
...@@ -143,8 +145,16 @@ def main(): ...@@ -143,8 +145,16 @@ def main():
# close the simulator # close the simulator
env.close() env.close()
simulation_app.close()
if __name__ == "__main__": if __name__ == "__main__":
try:
# run the main execution
main() main()
except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close()
...@@ -48,8 +48,10 @@ simulation_app = app_launcher.app ...@@ -48,8 +48,10 @@ simulation_app = app_launcher.app
import gym import gym
import traceback
from datetime import datetime from datetime import datetime
import carb
from skrl.agents.torch.ppo import PPO, PPO_DEFAULT_CONFIG from skrl.agents.torch.ppo import PPO, PPO_DEFAULT_CONFIG
from skrl.memories.torch import RandomMemory from skrl.memories.torch import RandomMemory
from skrl.utils import set_seed from skrl.utils import set_seed
...@@ -178,8 +180,16 @@ def main(): ...@@ -178,8 +180,16 @@ def main():
# close the simulator # close the simulator
env.close() env.close()
simulation_app.close()
if __name__ == "__main__": if __name__ == "__main__":
try:
# run the main execution
main() main()
except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close()
...@@ -65,7 +65,9 @@ simulation_app = SimulationApp(config) ...@@ -65,7 +65,9 @@ simulation_app = SimulationApp(config)
"""Rest everything follows.""" """Rest everything follows."""
import traceback
import carb
import omni.isaac.core.utils.prims as prim_utils import omni.isaac.core.utils.prims as prim_utils
from omni.isaac.cloner import GridCloner from omni.isaac.cloner import GridCloner
from omni.isaac.core.simulation_context import SimulationContext from omni.isaac.core.simulation_context import SimulationContext
...@@ -125,7 +127,13 @@ def main(): ...@@ -125,7 +127,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# Run cloning example try:
# run the main execution
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
...@@ -71,7 +71,9 @@ simulation_app = SimulationApp(config) ...@@ -71,7 +71,9 @@ simulation_app = SimulationApp(config)
"""Rest everything follows.""" """Rest everything follows."""
import os import os
import traceback
import carb
import omni.isaac.core.utils.stage as stage_utils import omni.isaac.core.utils.stage as stage_utils
import omni.kit.app import omni.kit.app
...@@ -134,7 +136,13 @@ def main(): ...@@ -134,7 +136,13 @@ def main():
if __name__ == "__main__": if __name__ == "__main__":
# Run cloning example try:
# run the main execution
main() main()
# Close the simulator except Exception as err:
carb.log_error(err)
carb.log_error(traceback.format_exc())
raise
finally:
# close sim app
simulation_app.close() simulation_app.close()
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