Unverified Commit cd54c89d authored by AutonomousHansen's avatar AutonomousHansen Committed by GitHub

Adds `AppLauncher` to configure the `SimulationApp` based on environment variables (#33)

# Description

Adds the class `AppLauncher` which takes configuration arguments to the
Isaac Sim `SimulationApp` and several environment variables. It launches
the SimulationApp and corresponding extensions in a controlled manner
allowing users to decide between different remote deployments, ROS
bridges, and viewport rendering.

AppLauncher can then be queried for logic on other SimulationApp
operations e.g. whether or not `SimulationContext.step()` should render
or not based on the resolved flags `AppLauncher.VIEWPORT` and
`AppLauncher.RENDER`.

Fixes #32 

## 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`
- [x] 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

---------
Co-authored-by: 's avatarFarbod Farshidian <ffarshidian@theaiinstitute.com>
Co-authored-by: 's avatarMayank Mittal <mittalma@leggedrobotics.com>
parent b4e78e60
......@@ -9,6 +9,7 @@ omni.isaac.orbit extension
orbit.actuators.group
orbit.actuators.model
orbit.app
orbit.asset_loader
orbit.devices
orbit.markers
......
omni.isaac.orbit.app
~~~~~~~~~~~~~~~~~~~~
.. automodule:: omni.isaac.orbit.app
:members:
:undoc-members:
......@@ -21,7 +21,7 @@ The tutorial corresponds to the ``play_empty.py`` script in the ``orbit/source/s
.. literalinclude:: ../../../source/standalone/demo/play_empty.py
:language: python
:emphasize-lines: 20-22,42-43,65-66,70-80,86-87
:emphasize-lines: 20-22,41-42,64-65,69-79,85-86
:linenos:
......@@ -54,9 +54,9 @@ we will be using in the script.
.. literalinclude:: ../../../source/standalone/demo/play_empty.py
:language: python
:lines: 28-32
:lines: 27-31
:linenos:
:lineno-start: 28
:lineno-start: 27
Designing the simulation scene
......@@ -83,9 +83,9 @@ existing UI elements.
.. literalinclude:: ../../../source/standalone/demo/play_empty.py
:language: python
:lines: 42-45
:lines: 41-44
:linenos:
:lineno-start: 42
:lineno-start: 41
Next, we add a ground plane and some lights into the scene. These objects are referred to as primitives or prims in
the USD definition. More concretely, prims are the basic building blocks of a USD scene. They can be considered
......@@ -107,9 +107,9 @@ property of a ``"SphereLight"`` prim is set to ``2.5``.
.. literalinclude:: ../../../source/standalone/demo/play_empty.py
:language: python
:lines: 50-63
:lines: 49-62
:linenos:
:lineno-start: 50
:lineno-start: 49
Running the simulation loop
......@@ -131,17 +131,17 @@ iteration of the loop.
.. literalinclude:: ../../../source/standalone/demo/play_empty.py
:language: python
:lines: 65-80
:lines: 64-79
:linenos:
:lineno-start: 65
:lineno-start: 64
Lastly, we call the :meth:`simulation_app.stop()` method to stop the simulation application and close the window.
Lastly, we call the :meth:`simulation_app.close()` method to stop the simulation application and close the window.
.. literalinclude:: ../../../source/standalone/demo/play_empty.py
:language: python
:lines: 86-87
:lines: 85-86
:linenos:
:lineno-start: 86
:lineno-start: 85
The Code Execution
~~~~~~~~~~~~~~~~~~
......
......@@ -22,7 +22,7 @@ For example, here is how you would wrap an environment to enforce that reset is
# create base environment
cfg = load_default_env_cfg("Isaac-Reach-Franka-v0")
env = gym.make("Isaac-Reach-Franka-v0", cfg=cfg, headless=True)
env = gym.make("Isaac-Reach-Franka-v0", cfg=cfg, render=True)
# wrap environment to enforce that reset is called before step
env = gym.wrappers.OrderEnforcing(env)
......@@ -55,7 +55,7 @@ is enabled. This can be done by setting the ``viewport`` argument to ``True`` wh
# create base environment
cfg = load_default_env_cfg("Isaac-Reach-Franka-v0")
env = gym.make("Isaac-Reach-Franka-v0", cfg=cfg, headless=True, viewport=True)
env = gym.make("Isaac-Reach-Franka-v0", cfg=cfg, render=True, viewport=True)
# wrap environment to enforce that reset is called before step
env = gym.wrappers.OrderEnforcing(env)
......@@ -100,7 +100,7 @@ records a video of the ``Isaac-Reach-Franka-v0`` environment for 200 steps, and
env_cfg.viewer.eye = (1.0, 1.0, 1.0)
env_cfg.viewer.lookat = (0.0, 0.0, 0.0)
# create isaac-env instance
env = gym.make(task_name, cfg=env_cfg, headless=headless, viewport=True)
env = gym.make(task_name, cfg=env_cfg, render=headless, viewport=True)
# wrap for video recording
video_kwargs = {
"video_folder": "videos",
......@@ -129,7 +129,7 @@ As an example of how to use the :class:`IsaacEnv` with Stable-Baselines3:
from omni.isaac.orbit_envs.utils.wrappers.sb3 import Sb3VecEnvWrapper
# create isaac-env instance
env = gym.make(task_name, cfg=env_cfg, headless=headless)
env = gym.make(task_name, cfg=env_cfg, render=headless)
# wrap around environment for stable baselines
env = Sb3VecEnvWrapper(env)
......
[package]
# Note: Semantic Versioning is used: https://semver.org/
version = "0.4.0"
version = "0.4.1"
# Description
title = "ORBIT framework for Robot Learning"
......
Changelog
---------
0.4.1 (2023-06-27)
~~~~~~~~~~~~~~~~~~
Added
^^^^^
* Added the :class:`omni.isaac.orbit.app.AppLauncher` class to allow controlled instantiation of
the `SimulationApp <https://docs.omniverse.nvidia.com/py/isaacsim/source/extensions/omni.isaac.kit/docs/index.html>`_
and extension loading for remote deployment and ROS bridges.
Changed
^^^^^^^
* Modified all standalone scripts to use the :class:`omni.isaac.orbit.app.AppLauncher` class.
0.4.0 (2023-05-27)
~~~~~~~~~~~~~~~~~~
......@@ -163,7 +179,7 @@ Added
Fixed
^^^^^
* Fixed setting of physics material on the ground plane when using :meth:``omni.isaac.orbit.utils.kit.create_ground_plane`` function.
* Fixed setting of physics material on the ground plane when using :meth:`omni.isaac.orbit.utils.kit.create_ground_plane` function.
0.1.0 (2023-01-17)
......
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES, ETH Zurich, and University of Toronto
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Utility to configure the ``omni.isaac.kit.SimulationApp`` based on environment variables.
Based on the desired functionality, this class parses environment variables and input keyword arguments
to launch the simulator in various different modes. This includes with or without GUI, switching between
different Omniverse remote clients, and enabling particular ROS bridges. Some of these require the
extensions to be loaded in a specific order, otherwise a segmentation fault occurs.
The launched `SimulationApp`_ instance is accessible via the :attr:`AppLauncher.app` property.
Available modes
---------------
The following details the behavior of the class based on the environment variables:
* **Headless mode**: If the environment variable ``REMOTE_DEPLOYMENT>0``, then SimulationApp will be started in headless mode.
* **Livestreaming**: If the environment variable ``REMOTE_DEPLOYMENT={2,3,4}`` , then `livestream`_ is enabled.
* ``REMOTE_DEPLOYMENT=1`` does not enable livestreaming, though it causes the app to run in headless mode.
* ``REMOTE_DEPLOYMENT=2`` enables streaming via the Isaac `Native Livestream`_ extension. This allows users to
connect through the Omniverse Streaming Client.
* ``REMOTE_DEPLOYMENT=3`` enables streaming via the `Websocket Livestream` extension. This allows users to
connect in a browser using the WebSocket protocol.
* ``REMOTE_DEPLOYMENT=4`` enables streaming via the `WebRTC Livestream` extension. This allows users to
connect in a browser using the WebRTC protocol.
* **Viewport**: If the environment variable ``VIEWPORT_ENABLED`` is set to non-zero, then the following behavior happens:
* ``VIEWPORT_ENABLED=1``: Ensures that the VIEWPORT member is set to true, to enable lightweight streaming
when the full GUI is not needed (i.e. headless mode).
* **Loading ROS Bridge**: If the environment variable ``ROS_ENABLED`` is set to non-zero, then the
following behavior happens:
* ``ROS_ENABLED=1``: Enables the ROS1 Noetic bridge in Isaac Sim.
* ``ROS_ENABLED=2``: Enables the ROS2 Foxy bridge in Isaac Sim.
.. caution::
Currently, in Isaac Sim 2022.2.1, loading ``omni.isaac.ros_bridge`` before ``omni.kit.livestream.native``
causes a segfault. Thus, to work around this issue, we enable the ROS-bridge extensions after the
livestreaming extensions.
Usage
-----
To set the environment variables, one can use the following command in the terminal:
.. code:: bash
export REMOTE_DEPLOYMENT=3
export VIEWPORT_ENABLED=1
# run the python script
./orbit.sh -p source/standalone/demo/play_quadrupeds.py
Alternatively, one can set the environment variables to the python script directly:
.. code:: bash
REMOTE_DEPLOYMENT=3 VIEWPORT_ENABLED=1 ./orbit.sh -p source/standalone/demo/play_quadrupeds.py
.. _SimulationApp: https://docs.omniverse.nvidia.com/py/isaacsim/source/extensions/omni.isaac.kit/docs/index.html
.. _livestream: https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/manual_livestream_clients.html
.. _`Native Livestream`: https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/manual_livestream_clients.html#isaac-sim-setup-kit-remote
.. _`Websocket Livestream`: https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/manual_livestream_clients.html#isaac-sim-setup-livestream-webrtc
.. _`WebRTC Livestream`: https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/manual_livestream_clients.html#isaac-sim-setup-livestream-websocket
"""
import os
from typing import ClassVar
import carb
from omni.isaac.kit import SimulationApp
__all__ = ["AppLauncher"]
class AppLauncher:
"""A class to create the simulation application based on keyword arguments and environment variables."""
RENDER: ClassVar[bool]
"""
Whether or not to render the GUI associated with IsaacSim.
This flag can be used in subsequent execution of the created simulator, i.e.
.. code:: python
from omni.isaac.core.simulation_context import SimulationContext
SimulationContext.instance().step(render=AppLauncher.RENDER)
Also, can be passed to :class:`IsaacEnv` instance using the :attr:`render` attribute, i.e.
.. code:: python
gym.make(render=app_launcher.RENDER, viewport=app_launcher.VIEWPORT)
"""
VIEWPORT: ClassVar[bool]
"""
Whether or not to render the lighter 'viewport' elements even when the application might be
executing in headless (no-GUI) mode. This is useful for off-screen rendering to gather images and
video more efficiently.
Also, can be passed to :class:`IsaacEnv` instance using the :attr:`viewport` attribute, i.e.
.. code:: python
gym.make(render=app_launcher.RENDER, viewport=app_launcher.VIEWPORT)
"""
def __init__(self, **kwargs):
"""Parses environments variables and keyword arguments to create a `SimulationApp`_ instance.
If the keyword argument ``headless`` is set to True, then the SimulationApp will be started in headless mode.
It will be given priority over the environment variable setting ``REMOTE_DEPLOYMENT=0``.
Args:
**kwargs: Keyword arguments passed to the :class:`SimulationApp` from Isaac Sim.
A detailed description of the possible arguments is available in its `documentation`_.
Raises:
ValueError: If incompatible or undefined values are assigned to relevant environment values,
such as ``REMOTE_DEPLOYMENT`` and ``ROS_ENABLED``
.. _SimulationApp: https://docs.omniverse.nvidia.com/py/isaacsim/source/extensions/omni.isaac.kit/docs/index.html
.. _documentation: https://docs.omniverse.nvidia.com/py/isaacsim/source/extensions/omni.isaac.kit/docs/index.html
"""
# Headless is always true for remote deployment
remote_deployment = int(os.environ.get("REMOTE_DEPLOYMENT", 0))
# resolve headless execution of simulation app
headless = kwargs.get("headless", False)
kwargs.update({"headless": headless or remote_deployment})
# launch simulation app
self._app = SimulationApp(kwargs)
# These have to be loaded after SimulationApp is initialized
from omni.isaac.core.utils.extensions import enable_extension
# Retrieve carb settings for modification
carb_settings_iface = carb.settings.get_settings()
if remote_deployment >= 2:
# Set carb settings to allow for livestreaming
carb_settings_iface.set_bool("/app/livestream/enabled", True)
carb_settings_iface.set_bool("/app/window/drawMouse", True)
carb_settings_iface.set_bool("/ngx/enabled", False)
carb_settings_iface.set_string("/app/livestream/proto", "ws")
carb_settings_iface.set_int("/app/livestream/websocket/framerate_limit", 120)
# Note: Only one livestream extension can be enabled at a time
if remote_deployment == 2:
# Enable Native Livestream extension
# Default App: Streaming Client from the Omniverse Launcher
enable_extension("omni.kit.livestream.native")
enable_extension("omni.services.streaming.manager")
elif remote_deployment == 3:
# Enable WebSocket Livestream extension
# Default URL: http://localhost:8211/streaming/client/
enable_extension("omni.services.streamclient.websocket")
elif remote_deployment == 4:
# Enable WebRTC Livestream extension
# Default URL: http://localhost:8211/streaming/webrtc-client/
enable_extension("omni.services.streamclient.webrtc")
else:
raise ValueError(
f"Invalid assignment for env variable `REMOTE_DEPLOYMENT`: {remote_deployment}. Expected 1, 2, 3, 4."
)
# As of IsaacSim 2022.1.1, the ros extension has to be loaded
# after the streaming extension or it will cause a segfault
ros = int(os.environ.get("ROS_ENABLED", 0))
# Note: Only one ROS bridge extension can be enabled at a time
if ros > 0:
if ros == 1:
enable_extension("omni.isaac.ros_bridge")
elif ros == 2:
enable_extension("omni.isaac.ros2_bridge")
else:
raise ValueError(f"Invalid assignment for env variable `ROS_ENABLED`: {ros}. Expected 1 or 2.")
# off-screen rendering
viewport = int(os.environ.get("VIEWPORT_ENABLED", 0))
# update the global flags
# -- render GUI
if headless and (remote_deployment < 2):
self.RENDER = False
else:
self.RENDER = True
# -- render viewport
if not viewport:
self.VIEWPORT = False
else:
self.VIEWPORT = True
@property
def app(self) -> SimulationApp:
"""The launched SimulationApp."""
if self._app is not None:
return self._app
else:
raise RuntimeError("The `AppLauncher.app` member cannot be retrieved until the class is initialized.")
Changelog
---------
0.3.1 (2023-06-23)
~~~~~~~~~~~~~~~~~~
Changed
^^^^^^^
* Changed the argument ``headless`` in :class:`IsaacEnv` class to ``render``, in order to cause less confusion
about rendering and headless-ness, i.e. that you can render while headless.
0.3.0 (2023-04-14)
~~~~~~~~~~~~~~~~~~
......
......@@ -71,29 +71,31 @@ class IsaacEnv(gym.Env):
metadata: ClassVar[Dict[str, Any]] = {"render.modes": ["human", "rgb_array"]}
"""Metadata for the environment."""
def __init__(self, cfg: IsaacEnvCfg, headless: bool = False, viewport: bool = False, **kwargs):
def __init__(self, cfg: IsaacEnvCfg, render: bool = False, viewport: bool = False, **kwargs):
"""Initialize the environment.
We currently support only PyTorch backend for the environment. In the future, we plan to extend this to use
other backends such as Warp.
If the environment is not headless and viewport is enabled, then the viewport will be rendered in the GUI.
This allows us to render the environment even in the headless mode. However, it will significantly slow
down the simulation. Thus, it is recommended to set both ``headless`` and ``viewport``
to ``False`` when training an environment (unless it uses perception sensors).
If render is True, then viewport is True, and the full rendering process will take place with
an interactive GUI available via local machine or streaming. If :obj:`render` is False and :obj:`viewport`
is True, then only the lighter-weight viewport elements will be rendered in the GUI. However, either of these
modes will significantly slow down the simulation compared to a non-rendering configuration. Thus, it
is recommended to set both :obj:`render` and :obj:`viewport` to False when training an environment (unless
it uses perception sensors).
Args:
cfg (IsaacEnvCfg): Instance of the environment configuration.
headless (bool, optional): Whether to render at every simulation step. Defaults to False.
viewport (bool, optional): Whether to enable the GUI viewport. If True, then the viewport
will be rendered in the GUI (even in the headless mode). Defaults to False.
render (bool, optional): Whether to render at every simulation step. Defaults to False.
viewport (bool, optional): Whether to enable the viewport/camera rendering. If True, then the viewport
will be rendered even if the GUI is disabled or :obj:`render` is False. Defaults to False.
Raises:
RuntimeError: No stage is found in the simulation.
"""
# store inputs to class
self.cfg = cfg
self.enable_render = not headless
self.enable_render = render
self.enable_viewport = viewport or self.enable_render
# extract commonly used parameters
self.num_envs = self.cfg.env.num_envs
......@@ -469,7 +471,7 @@ class IsaacEnv(gym.Env):
enable_extension("omni.kit.viewport.rtx")
# extension to make HydraDelegate renderers
enable_extension("omni.kit.viewport.pxr")
# enable viewport extension if not running in headless mode
# enable viewport extension if full rendering is enabled
enable_extension("omni.kit.viewport.bundle")
# load extra render extensions if requested
if self.enable_viewport:
......
......@@ -19,7 +19,7 @@ From the default configuration file for these robots, zero actions imply a defau
import argparse
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -28,9 +28,8 @@ parser.add_argument("--robot", type=str, default="franka_panda", help="Name of t
args_cli = parser.parse_args()
# launch omniverse app
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -121,7 +120,7 @@ def main():
break
# If simulation is paused, then skip.
if not sim.is_playing():
sim.step(render=not args_cli.headless)
sim.step(render=app_launcher.RENDER)
continue
# reset
if ep_step_count % 1000 == 0:
......@@ -145,7 +144,7 @@ def main():
# apply action to the robot
robot.apply_action(actions)
# perform step
sim.step()
sim.step(render=app_launcher.RENDER)
# update sim-time
sim_time += sim_dt
ep_step_count += 1
......
......@@ -14,7 +14,7 @@ the simulator or OpenGL convention for the camera, we use the robotics or ROS co
import argparse
# omni-isaac-orbit
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -24,9 +24,8 @@ parser.add_argument("--draw", action="store_true", default=False, help="Draw the
args_cli = parser.parse_args()
# launch omniverse app
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -159,10 +158,10 @@ def main():
break
# If simulation is paused, then skip.
if not sim.is_playing():
sim.step(render=not args_cli.headless)
sim.step(render=app_launcher.RENDER)
continue
# Step simulation
sim.step()
sim.step(render=app_launcher.RENDER)
# Update camera data
camera.update(dt=0.0)
......
......@@ -14,7 +14,7 @@ Reference: https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/tutorial_
import argparse
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -24,9 +24,8 @@ parser.add_argument("--num_robots", type=int, default=128, help="Number of robot
args_cli = parser.parse_args()
# launch omniverse app
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -146,7 +145,7 @@ def main():
break
# If simulation is paused, then skip.
if not sim.is_playing():
sim.step(render=not args_cli.headless)
sim.step(render=app_launcher.RENDER)
continue
# reset
if ep_step_count % 100 == 0:
......@@ -169,7 +168,7 @@ def main():
# apply actions
robot.apply_action(actions)
# perform step
sim.step()
sim.step(render=app_launcher.RENDER)
# update sim-time
sim_time += sim_dt
ep_step_count += 1
......
......@@ -10,7 +10,7 @@
import argparse
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -18,9 +18,8 @@ parser.add_argument("--headless", action="store_true", default=False, help="Forc
args_cli = parser.parse_args()
# launch omniverse app
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -74,10 +73,10 @@ def main():
break
# If simulation is paused, then skip.
if not sim.is_playing():
sim.step(render=not args_cli.headless)
sim.step(render=app_launcher.RENDER)
continue
# perform step
sim.step()
sim.step(render=app_launcher.RENDER)
if __name__ == "__main__":
......
......@@ -15,7 +15,7 @@ PhysX. This helps perform parallelized computation of the inverse kinematics.
import argparse
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -25,13 +25,11 @@ parser.add_argument("--num_envs", type=int, default=128, help="Number of environ
args_cli = parser.parse_args()
# launch omniverse app
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
import torch
import omni.isaac.core.utils.prims as prim_utils
......@@ -180,7 +178,7 @@ def main():
break
# If simulation is paused, then skip.
if not sim.is_playing():
sim.step(render=not args_cli.headless)
sim.step(render=app_launcher.RENDER)
continue
# reset
if count % 150 == 0:
......@@ -215,7 +213,7 @@ def main():
# apply actions
robot.apply_action(robot_actions)
# perform step
sim.step(render=not args_cli.headless)
sim.step(render=app_launcher.RENDER)
# update sim-time
sim_time += sim_dt
count += 1
......
......@@ -20,7 +20,7 @@ From the default configuration file for these robots, zero actions imply a stand
import argparse
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -28,9 +28,8 @@ parser.add_argument("--headless", action="store_true", default=False, help="Forc
args_cli = parser.parse_args()
# launch omniverse app
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -150,7 +149,7 @@ def main():
break
# If simulation is paused, then skip.
if not sim.is_playing():
sim.step(render=not args_cli.headless)
sim.step(render=app_launcher.RENDER)
continue
# reset
if count % 1000 == 0:
......@@ -170,7 +169,7 @@ def main():
robot_c.apply_action(actions)
robot_a.apply_action(actions)
# perform step
sim.step()
sim.step(render=app_launcher.RENDER)
# update sim-time
sim_time += sim_dt
count += 1
......
......@@ -18,7 +18,7 @@ From the default configuration file for these robots, zero actions imply a defau
import argparse
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -27,9 +27,8 @@ parser.add_argument("--robot", type=str, default="franka_panda", help="Name of t
args_cli = parser.parse_args()
# launch omniverse app
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -114,7 +113,7 @@ def main():
break
# If simulation is paused, then skip.
if not sim.is_playing():
sim.step(render=not args_cli.headless)
sim.step(render=app_launcher.RENDER)
continue
# reset
if ep_step_count % 1000 == 0:
......@@ -161,7 +160,7 @@ def main():
# apply action
robot.apply_action(actions)
# perform step
sim.step()
sim.step(render=app_launcher.RENDER)
# update sim-time
sim_time += sim_dt
ep_step_count += 1
......
......@@ -14,7 +14,7 @@ The RMP-Flow can be configured in different modes. It uses the LULA library for
import argparse
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -24,9 +24,8 @@ parser.add_argument("--num_envs", type=int, default=5, help="Number of environme
args_cli = parser.parse_args()
# launch omniverse app
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -180,7 +179,7 @@ def main():
break
# If simulation is paused, then skip.
if not sim.is_playing():
sim.step(render=not args_cli.headless)
sim.step(render=app_launcher.RENDER)
continue
# reset
if count % 350 == 0:
......@@ -200,7 +199,7 @@ def main():
# step simulation
# FIXME: this is needed for lula to update the buffers!
# the bug has been reported to the lula team
sim.step(render=not args_cli.headless)
sim.step(render=app_launcher.RENDER)
# set the controller commands
rmp_controller.set_command(rmp_commands)
# compute the joint commands
......@@ -232,7 +231,7 @@ def main():
# apply actions
robot.apply_action(robot_actions)
# perform step
sim.step(not args_cli.headless)
sim.step(render=app_launcher.RENDER)
# update sim-time
sim_time += sim_dt
count += 1
......
......@@ -12,7 +12,7 @@ This script demonstrates how to use the rigid objects class.
import argparse
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -20,9 +20,8 @@ parser.add_argument("--headless", action="store_true", default=False, help="Forc
args_cli = parser.parse_args()
# launch omniverse app
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -130,7 +129,7 @@ def main():
break
# If simulation is paused, then skip.
if not sim.is_playing():
sim.step(render=not args_cli.headless)
sim.step(render=app_launcher.RENDER)
continue
# reset
if count % 250 == 0:
......@@ -153,7 +152,7 @@ def main():
rigid_object.reset_buffers()
print(">>>>>>>> Reset!")
# perform step
sim.step()
sim.step(render=app_launcher.RENDER)
# update sim-time
sim_time += sim_dt
count += 1
......
......@@ -10,7 +10,7 @@
import argparse
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -20,9 +20,9 @@ parser.add_argument("--num_envs", type=int, default=None, help="Number of enviro
parser.add_argument("--task", type=str, default=None, help="Name of the task.")
args_cli = parser.parse_args()
# launch the simulator
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -40,7 +40,7 @@ def main():
# parse configuration
env_cfg = parse_env_cfg(args_cli.task, use_gpu=not args_cli.cpu, num_envs=args_cli.num_envs)
# create environment
env = gym.make(args_cli.task, cfg=env_cfg, headless=args_cli.headless)
env = gym.make(args_cli.task, cfg=env_cfg, render=app_launcher.RENDER, viewport=app_launcher.VIEWPORT)
# reset environment
env.reset()
......
......@@ -12,7 +12,7 @@ Usage:
import argparse
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -21,9 +21,9 @@ parser.add_argument("--cpu", action="store_true", default=False, help="Use CPU p
parser.add_argument("--num_envs", type=int, default=None, help="Number of environments to simulate.")
args_cli = parser.parse_args()
# launch the simulator
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything else."""
......@@ -240,7 +240,7 @@ def main():
# -- robot configuration
env_cfg.robot.robot_type = "franka"
# create environment
env = gym.make("Isaac-Lift-Franka-v0", cfg=env_cfg, headless=args_cli.headless)
env = gym.make("Isaac-Lift-Franka-v0", cfg=env_cfg, render=app_launcher.RENDER, viewport=app_launcher.VIEWPORT)
# create action buffers
actions = torch.zeros((env.num_envs, env.action_space.shape[0]), device=env.device)
......
......@@ -10,7 +10,7 @@
import argparse
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -22,9 +22,9 @@ parser.add_argument("--task", type=str, default=None, help="Name of the task.")
parser.add_argument("--sensitivity", type=float, default=1.0, help="Sensitivity factor.")
args_cli = parser.parse_args()
# launch the simulator
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -65,7 +65,7 @@ def main():
env_cfg.control.inverse_kinematics.command_type = "pose_rel"
env_cfg.terminations.episode_timeout = False
# create environment
env = gym.make(args_cli.task, cfg=env_cfg, headless=args_cli.headless)
env = gym.make(args_cli.task, cfg=env_cfg, render=app_launcher.RENDER, viewport=app_launcher.VIEWPORT)
# check environment name (for reach , we don't allow the gripper)
if "Reach" in args_cli.task:
carb.log_warn(
......
......@@ -10,7 +10,7 @@
import argparse
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -20,13 +20,12 @@ parser.add_argument("--num_envs", type=int, default=None, help="Number of enviro
parser.add_argument("--task", type=str, default=None, help="Name of the task.")
args_cli = parser.parse_args()
# launch the simulator
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
import gym
import torch
......@@ -40,7 +39,7 @@ def main():
# parse configuration
env_cfg = parse_env_cfg(args_cli.task, use_gpu=not args_cli.cpu, num_envs=args_cli.num_envs)
# create environment
env = gym.make(args_cli.task, cfg=env_cfg, headless=args_cli.headless)
env = gym.make(args_cli.task, cfg=env_cfg, render=app_launcher.RENDER, viewport=app_launcher.VIEWPORT)
# reset environment
env.reset()
......
......@@ -10,7 +10,7 @@
import argparse
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -26,9 +26,9 @@ parser.add_argument(
)
args_cli = parser.parse_args()
# launch the simulator
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -61,7 +61,7 @@ def main():
clip_actions = agent_cfg["params"]["env"].get("clip_actions", math.inf)
# create isaac environment
env = gym.make(args_cli.task, cfg=env_cfg, headless=args_cli.headless)
env = gym.make(args_cli.task, cfg=env_cfg, render=app_launcher.RENDER, viewport=app_launcher.VIEWPORT)
# wrap around environment for rl-games
env = RlGamesVecEnvWrapper(env, rl_device, clip_obs, clip_actions)
......
......@@ -11,7 +11,7 @@
import argparse
import os
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -32,9 +32,9 @@ if args_cli.headless:
app_experience = f"{os.environ['EXP_PATH']}/omni.isaac.sim.python.gym.headless.kit"
else:
app_experience = f"{os.environ['EXP_PATH']}/omni.isaac.sim.python.kit"
# launch the simulator
simulation_app = SimulationApp(config, experience=app_experience)
# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless, experience=app_experience)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -93,7 +93,7 @@ def main():
clip_actions = agent_cfg["params"]["env"].get("clip_actions", math.inf)
# create isaac environment
env = gym.make(args_cli.task, cfg=env_cfg, headless=args_cli.headless, viewport=args_cli.video)
env = gym.make(args_cli.task, cfg=env_cfg, render=app_launcher.RENDER, viewport=app_launcher.VIEWPORT)
# wrap for video recording
if args_cli.video:
video_kwargs = {
......
......@@ -10,7 +10,7 @@
import argparse
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -24,8 +24,8 @@ parser.add_argument("--filename", type=str, default="hdf_dataset", help="Basenam
args_cli = parser.parse_args()
# launch the simulator
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
app_launcher = AppLauncher()
simulation_app = app_launcher.create_app(headless=args_cli.headless)
"""Rest everything follows."""
......@@ -71,7 +71,7 @@ def main():
env_cfg.observations.return_dict_obs_in_group = True
# create environment
env = gym.make(args_cli.task, cfg=env_cfg, headless=args_cli.headless)
env = gym.make(args_cli.task, cfg=env_cfg, render=app_launcher.RENDER, viewport=app_launcher.VIEWPORT)
# create controller
if args_cli.device.lower() == "keyboard":
......
......@@ -10,7 +10,7 @@
import argparse
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -20,9 +20,9 @@ parser.add_argument("--task", type=str, default=None, help="Name of the task.")
parser.add_argument("--checkpoint", type=str, default=None, help="Pytorch model checkpoint to load.")
args_cli = parser.parse_args()
# launch the simulator
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -51,7 +51,7 @@ def main():
env_cfg.observations.return_dict_obs_in_group = True
# create environment
env = gym.make(args_cli.task, cfg=env_cfg, headless=args_cli.headless)
env = gym.make(args_cli.task, cfg=env_cfg, render=app_launcher.RENDER, viewport=app_launcher.VIEWPORT)
# acquire device
device = TorchUtils.get_torch_device(try_to_use_cuda=True)
......
......@@ -10,7 +10,7 @@
import argparse
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -21,9 +21,9 @@ parser.add_argument("--task", type=str, default=None, help="Name of the task.")
parser.add_argument("--checkpoint", type=str, default=None, help="Path to model checkpoint.")
args_cli = parser.parse_args()
# launch the simulator
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -48,7 +48,7 @@ def main():
agent_cfg = parse_rslrl_cfg(args_cli.task)
# create isaac environment
env = gym.make(args_cli.task, cfg=env_cfg, headless=args_cli.headless)
env = gym.make(args_cli.task, cfg=env_cfg, render=app_launcher.RENDER, viewport=app_launcher.VIEWPORT)
# wrap around environment for rsl-rl
env = RslRlVecEnvWrapper(env)
......
......@@ -11,7 +11,7 @@
import argparse
import os
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -31,8 +31,10 @@ if args_cli.headless:
app_experience = f"{os.environ['EXP_PATH']}/omni.isaac.sim.python.gym.headless.kit"
else:
app_experience = f"{os.environ['EXP_PATH']}/omni.isaac.sim.python.kit"
# launch the simulator
simulation_app = SimulationApp(config, experience=app_experience)
# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless, experience=app_experience)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -80,7 +82,7 @@ def main():
dump_pickle(os.path.join(log_dir, "params", "agent.pkl"), agent_cfg)
# create isaac environment
env = gym.make(args_cli.task, cfg=env_cfg, headless=args_cli.headless, viewport=args_cli.video)
env = gym.make(args_cli.task, cfg=env_cfg, render=app_launcher.RENDER, viewport=app_launcher.VIEWPORT)
# wrap for video recording
if args_cli.video:
video_kwargs = {
......
......@@ -11,7 +11,7 @@
import argparse
import numpy as np
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -22,9 +22,9 @@ parser.add_argument("--task", type=str, default=None, help="Name of the task.")
parser.add_argument("--checkpoint", type=str, default=None, help="Path to model checkpoint.")
args_cli = parser.parse_args()
# launch the simulator
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -47,7 +47,7 @@ def main():
# parse configuration
env_cfg = parse_env_cfg(args_cli.task, use_gpu=not args_cli.cpu, num_envs=args_cli.num_envs)
# create isaac environment
env = gym.make(args_cli.task, cfg=env_cfg, headless=args_cli.headless)
env = gym.make(args_cli.task, cfg=env_cfg, render=app_launcher.RENDER, viewport=app_launcher.VIEWPORT)
# wrap around environment for stable baselines
env = Sb3VecEnvWrapper(env)
# parse agent configuration
......
......@@ -12,7 +12,7 @@ import argparse
import numpy as np
import os
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -33,9 +33,9 @@ if args_cli.headless:
app_experience = f"{os.environ['EXP_PATH']}/omni.isaac.sim.python.gym.headless.kit"
else:
app_experience = f"{os.environ['EXP_PATH']}/omni.isaac.sim.python.kit"
# launch the simulator
simulation_app = SimulationApp(config, experience=app_experience)
# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless, experience=app_experience)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -81,7 +81,7 @@ def main():
n_timesteps = agent_cfg.pop("n_timesteps")
# create isaac environment
env = gym.make(args_cli.task, cfg=env_cfg, headless=args_cli.headless, viewport=args_cli.video)
env = gym.make(args_cli.task, cfg=env_cfg, render=app_launcher.RENDER, viewport=app_launcher.VIEWPORT)
# wrap for video recording
if args_cli.video:
video_kwargs = {
......
......@@ -16,7 +16,7 @@ a more user-friendly way.
import argparse
import os
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -27,9 +27,9 @@ parser.add_argument("--task", type=str, default=None, help="Name of the task.")
parser.add_argument("--checkpoint", type=str, default=None, help="Path to model checkpoint.")
args_cli = parser.parse_args()
# launch the simulator
config = {"headless": args_cli.headless}
simulation_app = SimulationApp(config)
# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -54,7 +54,7 @@ def main():
experiment_cfg = parse_skrl_cfg(args_cli.task)
# create isaac environment
env = gym.make(args_cli.task, cfg=env_cfg, headless=args_cli.headless)
env = gym.make(args_cli.task, cfg=env_cfg, render=app_launcher.RENDER, viewport=app_launcher.VIEWPORT)
# wrap around environment for skrl
env = SkrlVecEnvWrapper(env) # same as: `wrap_env(env, wrapper="isaac-orbit")`
......
......@@ -16,7 +16,7 @@ a more user-friendly way.
import argparse
import os
from omni.isaac.kit import SimulationApp
from omni.isaac.orbit.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser("Welcome to Orbit: Omniverse Robotics Environments!")
......@@ -37,8 +37,10 @@ if args_cli.headless:
app_experience = f"{os.environ['EXP_PATH']}/omni.isaac.sim.python.gym.headless.kit"
else:
app_experience = f"{os.environ['EXP_PATH']}/omni.isaac.sim.python.kit"
# launch the simulator
simulation_app = SimulationApp(config, experience=app_experience)
# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless, experience=app_experience)
simulation_app = app_launcher.app
"""Rest everything follows."""
......@@ -92,7 +94,7 @@ def main():
dump_pickle(os.path.join(log_dir, "params", "agent.pkl"), experiment_cfg)
# create isaac environment
env = gym.make(args_cli.task, cfg=env_cfg, headless=args_cli.headless, viewport=args_cli.video)
env = gym.make(args_cli.task, cfg=env_cfg, render=app_launcher.RENDER, viewport=app_launcher.VIEWPORT)
# wrap for video recording
if args_cli.video:
video_kwargs = {
......
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