Skip to content

Commit

Permalink
Adds method for simulation CLI arguments to the AppLauncher class (#…
Browse files Browse the repository at this point in the history
…160)

# Description

Adds `add_app_launcher_args` function to the `AppLauncher` class, which
can be used to add AppLauncher-specific arguments to an existing
ArgumentParser instance.

Because everything we pass is then passed to SimulationApp as a config,
the MR also adds the `check_config()` function. This compares the key
values of a dict and raises a ValueError in the following cases:
* if they have a key reserved for a SimulationApp config parameter but
incorrect value types
* if the value type is correct, it informs the user if a dict item they
passed will be interpreted as a SimulationApp config parameter.
Non-SimulationApp relevant keys are cleaned from the dict before it is
passed to SimulationApp.

Also separated out the giant `AppLauncher.__init__` function into a few
sub-functions to make things more readable.

## Type of change

- New feature (non-breaking change which adds functionality)

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

---------

Signed-off-by: AutonomousHansen <[email protected]>
Co-authored-by: Mayank Mittal <[email protected]>
  • Loading branch information
hhansen-bdai and Mayankm96 authored Oct 17, 2023
1 parent 3473efb commit 39f9549
Show file tree
Hide file tree
Showing 32 changed files with 700 additions and 125 deletions.
4 changes: 2 additions & 2 deletions docs/source/refs/license.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
License
=======
========

NVIDIA Isaac Sim is available freely under `indivudal license
NVIDIA Isaac Sim is available freely under `individual license
<https://www.nvidia.com/en-us/omniverse/download/>`_. For more information
about its license terms, please check `here <https://docs.omniverse.nvidia.com/app_isaacsim/common/NVIDIA_Omniverse_License_Agreement.html#software-support-supplement>`_.
The license files for all its dependencies and included assets are available in its
Expand Down
2 changes: 1 addition & 1 deletion source/extensions/omni.isaac.orbit/config/extension.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

# Note: Semantic Versioning is used: https://semver.org/
version = "0.9.9"
version = "0.9.10"

# Description
title = "ORBIT framework for Robot Learning"
Expand Down
20 changes: 18 additions & 2 deletions source/extensions/omni.isaac.orbit/docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
Changelog
---------

0.9.10 (2023-10-16)
~~~~~~~~~~~~~~~~~~~

Added
^^^^^

* Added `livestream` and `ros` CLI args to :class:`omni.isaac.orbit.app.AppLauncher` class.
* Added a static function :meth:`omni.isaac.orbit.app.AppLauncher.add_app_launcher_args`, which
appends the arguments needed for :class:`omni.isaac.orbit.app.AppLauncher` to the argument parser.

Changed
^^^^^^^

* Within :class:`omni.isaac.orbit.app.AppLauncher`, removed `REMOTE_DEPLOYMENT` env-var processing
in the favor of ``HEADLESS`` and ``LIVESTREAM`` env-vars. These have clearer uses and better parity
with the CLI args.


0.9.9 (2023-10-12)
~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -28,8 +46,6 @@ Fixed
* Fixed the boundedness of class objects that register callbacks into the simulator.
These include devices, :class:`AssetBase`, :class:`SensorBase` and :class:`CommandGenerator`.
The fix ensures that object gets deleted when the user deletes the object.


0.9.7 (2023-09-26)
~~~~~~~~~~~~~~~~~~

Expand Down
521 changes: 455 additions & 66 deletions source/extensions/omni.isaac.orbit/omni/isaac/orbit/app.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES, ETH Zurich, and University of Toronto
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause

from __future__ import annotations

import argparse
import unittest
from unittest import mock

from omni.isaac.orbit.app import AppLauncher


class TestAppLauncher(unittest.TestCase):
"""Test launching of the simulation app using AppLauncher."""

@mock.patch("argparse.ArgumentParser.parse_args", return_value=argparse.Namespace(livestream=1))
def test_livestream_launch_with_argparser(self, mock_args):
"""Test launching with argparser arguments."""
# create argparser
parser = argparse.ArgumentParser()
# add app launcher arguments
AppLauncher.add_app_launcher_args(parser)
# check that argparser has the mandatory arguments
for name in AppLauncher._APPLAUNCHER_CONFIG_TYPES:
self.assertTrue(parser._option_string_actions[f"--{name}"])
# parse args
mock_args = parser.parse_args()
# everything defaults to None
app = AppLauncher(mock_args).app

# import settings
import carb

# acquire settings interface
carb_settings_iface = carb.settings.get_settings()
# check settings
# -- no-gui mode
self.assertEqual(carb_settings_iface.get("/app/window/enabled"), False)
# -- livestream
self.assertEqual(carb_settings_iface.get("/app/livestream/enabled"), True)

# close the app on exit
app.close()


if __name__ == "__main__":
unittest.main()
40 changes: 40 additions & 0 deletions source/extensions/omni.isaac.orbit/test/app/test_env_var_launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES, ETH Zurich, and University of Toronto
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause

from __future__ import annotations

import os
import unittest

from omni.isaac.orbit.app import AppLauncher


class TestAppLauncher(unittest.TestCase):
"""Test launching of the simulation app using AppLauncher."""

def test_livestream_launch_with_env_var(self):
"""Test launching with no-keyword args but environment variables."""
# manually set the settings as well to make sure they are set correctly
os.environ["LIVESTREAM"] = "1"
# everything defaults to None
app = AppLauncher().app

# import settings
import carb

# acquire settings interface
carb_settings_iface = carb.settings.get_settings()
# check settings
# -- no-gui mode
self.assertEqual(carb_settings_iface.get("/app/window/enabled"), False)
# -- livestream
self.assertEqual(carb_settings_iface.get("/app/livestream/enabled"), True)

# close the app on exit
app.close()


if __name__ == "__main__":
unittest.main()
37 changes: 37 additions & 0 deletions source/extensions/omni.isaac.orbit/test/app/test_kwarg_launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES, ETH Zurich, and University of Toronto
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause

from __future__ import annotations

import unittest

from omni.isaac.orbit.app import AppLauncher


class TestAppLauncher(unittest.TestCase):
"""Test launching of the simulation app using AppLauncher."""

def test_livestream_launch_with_kwarg(self):
"""Test launching with headless and livestreaming arguments."""
# everything defaults to None
app = AppLauncher(headless=True, livestream=1).app

# import settings
import carb

# acquire settings interface
carb_settings_iface = carb.settings.get_settings()
# check settings
# -- no-gui mode
self.assertEqual(carb_settings_iface.get("/app/window/enabled"), False)
# -- livestream
self.assertEqual(carb_settings_iface.get("/app/livestream/enabled"), True)

# close the app on exit
app.close()


if __name__ == "__main__":
unittest.main()
9 changes: 4 additions & 5 deletions source/standalone/demo/play_arms.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,18 @@
parser = argparse.ArgumentParser(
description="This script demonstrates how to use the physics engine to simulate a single-arm manipulator."
)
parser.add_argument("--headless", action="store_true", default=False, help="Force display off at all times.")
parser.add_argument(
"--robot", type=str, default="franka_panda", choices=["franka_panda", "ur10"], help="Name of the robot."
)
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()

# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app

"""Rest everything follows."""


import torch
import traceback

Expand Down
6 changes: 4 additions & 2 deletions source/standalone/demo/play_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@

# add argparse arguments
parser = argparse.ArgumentParser(description="This script demonstrates how to use the camera sensor.")
parser.add_argument("--headless", action="store_true", default=False, help="Force display off at all times.")
parser.add_argument("--gpu", action="store_true", default=False, help="Use GPU device for camera rendering output.")
parser.add_argument("--draw", action="store_true", default=False, help="Draw the obtained pointcloud on viewport.")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()

# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app

"""Rest everything follows."""
Expand Down
6 changes: 4 additions & 2 deletions source/standalone/demo/play_cloner.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@

# add argparse arguments
parser = argparse.ArgumentParser(description="This script demonstrates how to use the cloner API from Isaac Sim.")
parser.add_argument("--headless", action="store_true", default=False, help="Force display off at all times.")
parser.add_argument("--robot", type=str, default="franka_panda", help="Name of the robot.")
parser.add_argument("--num_robots", type=int, default=128, help="Number of robots to spawn.")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()

# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app

"""Rest everything follows."""
Expand Down
6 changes: 4 additions & 2 deletions source/standalone/demo/play_empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@

# add argparse arguments
parser = argparse.ArgumentParser(description="This script creates an empty stage in Isaac Sim.")
parser.add_argument("--headless", action="store_true", default=False, help="Force display off at all times.")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()

# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app

"""Rest everything follows."""
Expand Down
6 changes: 4 additions & 2 deletions source/standalone/demo/play_ik_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@

# add argparse arguments
parser = argparse.ArgumentParser(description="This script demonstrates how to use the inverse kinematics controller.")
parser.add_argument("--headless", action="store_true", default=False, help="Force display off at all times.")
parser.add_argument("--robot", type=str, default="franka_panda", help="Name of the robot.")
parser.add_argument("--num_envs", type=int, default=128, help="Number of environments to spawn.")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()

# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app

"""Rest everything follows."""
Expand Down
4 changes: 3 additions & 1 deletion source/standalone/demo/play_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
parser = argparse.ArgumentParser(
description="This script demonstrates how to create different types of markers in Orbit."
)
parser.add_argument("--headless", action="store_true", default=False, help="Force display off at all times.")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()

# launch omniverse app
Expand Down
6 changes: 4 additions & 2 deletions source/standalone/demo/play_quadrupeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@

# add argparse arguments
parser = argparse.ArgumentParser(description="This script demonstrates how to simulate a legged robot.")
parser.add_argument("--headless", action="store_true", default=False, help="Force display off at all times.")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()

# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app

"""Rest everything follows."""
Expand Down
6 changes: 4 additions & 2 deletions source/standalone/demo/play_ridgeback_franka.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
parser = argparse.ArgumentParser(
description="This script demonstrates how to simulate a mobile manipulator with dummy joints."
)
parser.add_argument("--headless", action="store_true", default=False, help="Force display off at all times.")
parser.add_argument("--robot", type=str, default="franka_panda", help="Name of the robot.")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()

# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app

"""Rest everything follows."""
Expand Down
6 changes: 4 additions & 2 deletions source/standalone/demo/play_rmpflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
parser = argparse.ArgumentParser(
description="This script demonstrates how to use the RMPFlow controller with the simulator."
)
parser.add_argument("--headless", action="store_true", default=False, help="Force display off at all times.")
parser.add_argument("--robot", type=str, default="ur10", help="Name of the robot. Options: franka_panda, ur10.")
parser.add_argument("--num_envs", type=int, default=5, help="Number of environments to spawn.")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()

# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app

"""Rest everything follows."""
Expand Down
6 changes: 4 additions & 2 deletions source/standalone/demo/play_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@

# add argparse arguments
parser = argparse.ArgumentParser(description="This script demonstrates how to use the scene interface.")
parser.add_argument("--headless", action="store_true", default=False, help="Force display off at all times.")
parser.add_argument("--num_envs", type=int, default=2, help="Number of environments to spawn.")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()

# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app

"""Rest everything follows."""
Expand Down
6 changes: 4 additions & 2 deletions source/standalone/demo/play_ycb_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@

# add argparse arguments
parser = argparse.ArgumentParser(description="Load YCB objects in Orbit and randomize their poses.")
parser.add_argument("--headless", action="store_true", default=False, help="Force display off at all times.")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()

# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app

"""Rest everything follows."""
Expand Down
6 changes: 4 additions & 2 deletions source/standalone/environments/random_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@

# add argparse arguments
parser = argparse.ArgumentParser(description="Random agent for Isaac Orbit environments.")
parser.add_argument("--headless", action="store_true", default=False, help="Force display off at all times.")
parser.add_argument("--cpu", action="store_true", default=False, help="Use CPU pipeline.")
parser.add_argument("--num_envs", type=int, default=None, help="Number of environments to simulate.")
parser.add_argument("--task", type=str, default=None, help="Name of the task.")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()

# launch omniverse app
app_launcher = AppLauncher(headless=args_cli.headless)
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app

"""Rest everything follows."""
Expand Down
Loading

0 comments on commit 39f9549

Please sign in to comment.