Unverified Commit 8f8c3700 authored by Mayank Mittal's avatar Mayank Mittal Committed by GitHub

Fixes warnings when launching app from AppLauncher class (#99)

# Description

Previously, while launching the simulation app, there were warnings at
the start of the file that complained that:

```
[Warning] [omni.isaac.kit.simulation_app] Modules: ['omni.isaac.orbit', 'omni.isaac.orbit.app', 'omni.isaac.kit.app_framework'] were loaded before SimulationApp was started and might not be loaded correctly.
[Warning] [omni.isaac.kit.simulation_app] Please check to make sure no extra omniverse or pxr modules are imported before the call to SimulationApp(...)
```

This is because of a manual check inside the `SimulationApp` class where
they check the `sys.modules` against "accepted" packages that are
hardcoded. The PR fixes this issue by removing the orbit packages from
`sys.modules` before launching the simulation app.

## 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
`./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
- [x] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
parent 815de7a2
[package] [package]
# Note: Semantic Versioning is used: https://semver.org/ # Note: Semantic Versioning is used: https://semver.org/
version = "0.8.0" version = "0.8.1"
# Description # Description
title = "ORBIT framework for Robot Learning" title = "ORBIT framework for Robot Learning"
......
Changelog Changelog
--------- ---------
0.8.1 (2023-08-02)
~~~~~~~~~~~~~~~~~~
Fixed
^^^^^
* Added a hack into :class:`omni.isaac.orbit.app.AppLauncher` class to remove orbit packages from the path before launching
the simulation application. This prevents the warning messages that appears when the user launches the ``SimulationApp``.
Added
^^^^^
* Enabled necessary viewport extensions in the :class:`omni.isaac.orbit.app.AppLauncher` class itself if ``VIEWPORT_ENABLED``
flag is true.
0.8.0 (2023-07-26) 0.8.0 (2023-07-26)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
......
...@@ -73,6 +73,8 @@ Alternatively, one can set the environment variables to the python script direct ...@@ -73,6 +73,8 @@ Alternatively, one can set the environment variables to the python script direct
""" """
import os import os
import re
import sys
from typing import ClassVar from typing import ClassVar
import carb import carb
...@@ -136,10 +138,23 @@ class AppLauncher: ...@@ -136,10 +138,23 @@ class AppLauncher:
# Headless is always true for remote deployment # Headless is always true for remote deployment
remote_deployment = int(os.environ.get("REMOTE_DEPLOYMENT", 0)) remote_deployment = int(os.environ.get("REMOTE_DEPLOYMENT", 0))
# resolve headless execution of simulation app # resolve headless execution of simulation app
headless = kwargs.get("headless", False) headless = kwargs.get("headless", False) or remote_deployment
kwargs.update({"headless": headless or remote_deployment}) kwargs.update({"headless": headless})
# hack sys module to make sure that the SimulationApp is initialized correctly
# this is to avoid the warnings from the simulation app about not ok modules
r = re.compile(".*orbit.*")
found_modules = list(filter(r.match, list(sys.modules.keys())))
found_modules += ["omni.isaac.kit.app_framework"]
# remove orbit modules from sys.modules
hacked_modules = dict()
for key in found_modules:
hacked_modules[key] = sys.modules[key]
del sys.modules[key]
# launch simulation app # launch simulation app
self._app = SimulationApp(kwargs) self._app = SimulationApp(kwargs)
# add orbit modules back to sys.modules
for key, value in hacked_modules.items():
sys.modules[key] = value
# These have to be loaded after SimulationApp is initialized # These have to be loaded after SimulationApp is initialized
from omni.isaac.core.utils.extensions import enable_extension from omni.isaac.core.utils.extensions import enable_extension
...@@ -187,8 +202,29 @@ class AppLauncher: ...@@ -187,8 +202,29 @@ class AppLauncher:
# off-screen rendering # off-screen rendering
viewport = int(os.environ.get("VIEWPORT_ENABLED", 0)) viewport = int(os.environ.get("VIEWPORT_ENABLED", 0))
# enable extensions for off-screen rendering
# note: depending on the app file, some extensions might not be available in it.
# Thus, we manually enable these extensions to make sure they are available.
if viewport > 0 or not headless:
# note: enabling extensions is order-sensitive. please do not change the order!
# extension to enable UI buttons (otherwise we get attribute errors)
enable_extension("omni.kit.window.toolbar")
# extension to make RTX realtime and path-traced renderers
enable_extension("omni.kit.viewport.rtx")
# extension to make HydraDelegate renderers
enable_extension("omni.kit.viewport.pxr")
# enable viewport extension if full rendering is enabled
enable_extension("omni.kit.viewport.bundle")
# extension for window status bar
enable_extension("omni.kit.window.status_bar")
# enable isaac replicator extension
# note: moved here since it requires to have the viewport extension to be enabled first.
enable_extension("omni.replicator.isaac")
# enable urdf importer
enable_extension("omni.isaac.urdf")
# update the global flags # update the global flags
# TODO: Remove all these global flags. We don't need it anymore.
# -- render GUI # -- render GUI
if headless and (remote_deployment < 2): if headless and (remote_deployment < 2):
self.RENDER = False self.RENDER = False
......
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