Skip to content

Commit

Permalink
Migrates framework to support Isaac Sim 2023.1 (#172)
Browse files Browse the repository at this point in the history
# Description

From Isaac Sim 2023.X onwards (Kit 105.X onwards), there are various
noticeable changes that include renaming certain extensions and
upgrading to the latest USD.

This MR ensures that Orbit remains compatible with the coming release of
Isaac Sim while still supporting 2022.2.1.

## Type of change

- Bug fix (non-breaking change which fixes an issue)
- 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
- [ ] 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

---------

Signed-off-by: Mayank Mittal <[email protected]>
Co-authored-by: Nikita Rudin <[email protected]>
Co-authored-by: AutonomousHansen <[email protected]>
Co-authored-by: jsmith-bdai <[email protected]>
  • Loading branch information
4 people authored Oct 13, 2023
1 parent c719c59 commit 588bd36
Show file tree
Hide file tree
Showing 48 changed files with 337 additions and 271 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ per-file-ignores=*/__init__.py:F401
ignore=E402,E501,W503,E203,D401,R504,R505,SIM102,SIM117
max-line-length = 120
max-complexity = 30
exclude=_*,.vscode,.git,docs/**,**/test/**
exclude=_*,.vscode,.git,docs/**
# docstrings
docstring-convention=google
# annotations
Expand Down
9 changes: 5 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
apt -y autoremove && apt clean autoclean && \
rm -rf /var/lib/apt/lists/*

# FIXME: Only necessary for streaming until this fix is properly
# rolled out by NVIDIA after Isaac Sim2023.1 release
# FIXME: Only necessary for streaming until this fix is properly rolled out by NVIDIA after Isaac Sim2023.1 release
# Ref: https://forums.developer.nvidia.com/t/running-a-standalone-example-with-gui-in-docker-container/248147/3
RUN sed -i 's/\("omni.isaac.quadruped"\s=\s{}\)/"omni.isaac.quadruped" = {order = 10}/g' \
${ISAACSIM_PATH}/apps/omni.isaac.sim.python.kit
RUN if [[ "${ISAACSIM_VERSION}" == "2022.2"* ]]; then \
sed -i 's/\("omni.isaac.quadruped"\s=\s{}\)/"omni.isaac.quadruped" = {order = 10}/g' \
${ISAACSIM_PATH}/apps/omni.isaac.sim.python.kit \
fi

# Copy the orbit directory
COPY ../ ${ORBIT_PATH}
Expand Down
6 changes: 5 additions & 1 deletion docker/container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,22 @@ case $mode in
echo "[INFO] Copying artifacts from the 'orbit' container..."
echo -e "\t - /workspace/orbit/logs -> ${SCRIPT_DIR}/artifacts/logs"
echo -e "\t - /workspace/orbit/docs/_build -> ${SCRIPT_DIR}/artifacts/docs/_build"
echo -e "\t - /workspace/orbit/data_storage -> ${SCRIPT_DIR}/artifacts/data_storage"
# enter the script directory
pushd ${SCRIPT_DIR} > /dev/null 2>&1
# We have to remove before copying because repeated copying without deletion
# causes strange errors such as nested _build directories
# warn the user
echo -e "[WARN] Removing the existing artifacts...\n"
rm -rf ./artifacts/logs ./artifacts/docs/_build
rm -rf ./artifacts/logs ./artifacts/docs/_build ./artifacts/data_storage

# create the directories
mkdir -p ./artifacts/docs

# copy the artifacts
docker cp orbit:/workspace/orbit/logs ./artifacts/logs
docker cp orbit:/workspace/orbit/docs/_build ./artifacts/docs/_build
docker cp orbit:/workspace/orbit/data_storage ./artifacts/data_storage
echo -e "\n[INFO] Finished copying the artifacts from the container."
popd > /dev/null 2>&1
;;
Expand Down
24 changes: 16 additions & 8 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ services:
# These volumes follow from this page
# https://docs.omniverse.nvidia.com/app_isaacsim/app_isaacsim/install_faq.html#save-isaac-sim-configs-on-local-disk
- type: volume
source: isaac-cache
target: ${DOCKER_ISAACSIM_PATH}/kit/cache/Kit
source: isaac-cache-kit
target: ${DOCKER_ISAACSIM_PATH}/kit/cache
- type: volume
source: isaac-cache
source: isaac-cache-ov
target: ${DOCKER_USER_HOME}/.cache/ov
- type: volume
source: isaac-cache
source: isaac-cache-pip
target: ${DOCKER_USER_HOME}/.cache/pip
- type: volume
source: isaac-cache
source: isaac-cache-gl
target: ${DOCKER_USER_HOME}/.cache/nvidia/GLCache
- type: volume
source: isaac-cache
source: isaac-cache-compute
target: ${DOCKER_USER_HOME}/.nv/ComputeCache
- type: volume
source: isaac-logs
Expand Down Expand Up @@ -67,10 +67,13 @@ services:
# to the host machine
- type: volume
source: orbit-docs
target: /workspace/orbit/docs/_build/
target: /workspace/orbit/docs/_build
- type: volume
source: orbit-logs
target: /workspace/orbit/logs
- type: volume
source: orbit-data
target: /workspace/orbit/data_storage
network_mode: host
deploy:
resources:
Expand All @@ -86,10 +89,15 @@ services:

volumes:
# isaac-sim
isaac-cache:
isaac-cache-kit:
isaac-cache-ov:
isaac-cache-pip:
isaac-cache-gl:
isaac-cache-compute:
isaac-logs:
isaac-data:
isaac-docs:
# orbit
orbit-docs:
orbit-logs:
orbit-data:
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"omni.isaac.kit",
"omni.isaac.cloner",
"omni.isaac.urdf",
"omni.isaac.version",
"gym",
"skrl",
"stable_baselines3",
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ If you use ``orbit`` in your work, please cite the `paper <https://arxiv.org/abs
:caption: References

source/refs/faq
source/refs/migration
source/refs/contributing
source/refs/troubleshooting
source/refs/issues
Expand Down
93 changes: 93 additions & 0 deletions docs/source/refs/migration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Migration Guide (Isaac Sim)
===========================

Moving from Isaac Sim 2022.2.1 to 2023.1.0 brings in a number of changes to the
APIs and the way the application is built. This document outlines the changes
and how to migrate your code to the new APIs. Many of these changes attribute to
the underlying Omniverse Kit upgrade from 104.2 to 105.1. The new upgrade brings
the following notable changes:

* Update to USD 22.11
* Upgrading the Python from 3.7 to 3.10


.. warning::
This document is a work in progress and will be updated as we move closer
to the release of Isaac Sim 2023.1.0.


Renaming of PhysX Flatcache to PhysX Fabric
-------------------------------------------

The PhysX Flatcache has been renamed to PhysX Fabric. The new name is more
descriptive of the functionality and is consistent with the naming convention
used by Omniverse called `Fabric`_. Consequently, the Python module name has
also been changed from :mod:`omni.physxflatcache` to :mod:`omni.physxfabric`.

Following this, on the Isaac Sim side, various renaming have occurred:

* The parameter passed to :class:`SimulationContext` constructor via the keyword :obj:`sim_params`
now expects the key ``use_fabric`` instead of ``use_flatcache``.
* The Python attribute :attr:`SimulationContext.get_physics_context().use_flatcache` is now
:attr:`SimulationContext.get_physics_context().use_fabric`.
* The Python function :meth:`SimulationContext.get_physics_context().enable_flatcache` is now
:meth:`SimulationContext.get_physics_context().enable_fabric`.


Renaming of the URDF and MJCF Importers
---------------------------------------

Starting from Isaac Sim 2023.1, the URDF and MJCF importers have been renamed to be more consistent
with the other asset importers in Omniverse. The importers are now available on NVIDIA-Omniverse GitHub
as open source projects.

Due to the extension name change, the Python module names have also been changed:

* URDF Importer: :mod:`omni.importer.urdf` (previously :mod:`omni.isaac.urdf`)
* MJCF Importer: :mod:`omni.importer.mjcf` (previously :mod:`omni.isaac.mjcf`)


Deprecation of :class:`UsdLux.Light` API
----------------------------------------

As highlighted in the release notes of `USD 22.11`_, the ``UsdLux.Light`` API has
been deprecated in favor of the new ``UsdLuxLightAPI`` API. In the new API the attributes
are prefixed with ``inputs:``. For example, the ``intensity`` attribute is now available as
``inputs:intensity``.

The following example shows how to create a `SphereLight` using the old API and
the new API.

.. dropdown:: :fa:`eye,mr-1` Code for Isaac Sim 2022.2.1 and below

.. code-block:: python
import omni.isaac.core.utils.prims as prim_utils
prim_utils.create_prim(
"/World/Light/GreySphere",
"SphereLight",
translation=(4.5, 3.5, 10.0),
attributes={"radius": 2.5, "intensity": 600.0, "color": (0.75, 0.75, 0.75)},
)
.. dropdown:: :fa:`eye,mr-1` Code for Isaac Sim 2023.1.0 and above

.. code-block:: python
import omni.isaac.core.utils.prims as prim_utils
prim_utils.create_prim(
"/World/Light/WhiteSphere",
"SphereLight",
translation=(-4.5, 3.5, 10.0),
attributes={
"inputs:radius": 2.5,
"inputs:intensity": 600.0,
"inputs:color": (1.0, 1.0, 1.0)
},
)
.. _Fabric: https://docs.omniverse.nvidia.com/kit/docs/usdrt/latest/docs/usd_fabric_usdrt.html
.. _`USD 22.11`: https://github.com/PixarAnimationStudios/OpenUSD/blob/release/CHANGELOG.md
29 changes: 17 additions & 12 deletions docs/source/setup/docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ needed to run Orbit inside a Docker container. These are summarized below:

* ``Dockerfile``: Defines orbit image by overlaying Orbit dependencies onto the Isaac Sim Docker image.
* ``docker-compose.yaml``: Creates mounts to allow direct editing of Orbit code from the host machine that runs
the container along with X11 forwarding. It also creates several named volumes such as ``isaac-cache`` to store frequently
the container along with X11 forwarding. It also creates several named volumes such as ``isaac-cache-kit`` to store frequently
re-used resources compiled by Isaac Sim, such as shaders, and to retain logs, data, and documents.
* ``.env``: Stores environment variables required for the build process and the container itself.
* ``container.sh``: A script that wraps the ``docker-compose`` command to build the image and run the container.
Expand All @@ -104,7 +104,7 @@ The script ``container.sh`` wraps around three basic ``docker-compose`` commands
1. ``start``: This builds the image and brings up the container in detached mode (i.e. in the background).
2. ``enter``: This begins a new bash process in an existing orbit container, and which can be exited
without bringing down the container.
3. ``copy``: This copies the ``logs`` and ``docs/_build`` artifacts, from the ``orbit-logs`` and ``orbit-docs``
3. ``copy``: This copies the ``logs``, ``data_storage`` and ``docs/_build`` artifacts, from the ``orbit-logs``, ``orbit-data`` and ``orbit-docs``
volumes respectively, to the ``docker/artifacts`` directory. These artifacts persist between docker
container instances.
4. ``stop``: This brings down the container and removes it.
Expand All @@ -125,8 +125,8 @@ To copy files from the container to the host machine, you can use the following
# Copy the file /workspace/orbit/logs to the current directory
docker cp orbit:/workspace/orbit/logs .
The script ``container.sh`` provides a wrapper around this command to copy the ``logs`` and ``docs/_build``
directories to the ``docker/artifacts`` directory. This is useful for copying the logs and documentation:
The script ``container.sh`` provides a wrapper around this command to copy the ``logs`` , ``data_storage`` and ``docs/_build``
directories to the ``docker/artifacts`` directory. This is useful for copying the logs, data and documentation:

.. code:: bash
Expand Down Expand Up @@ -163,21 +163,26 @@ Understanding the mounted volumes
The ``docker-compose.yaml`` file creates several named volumes that are mounted to the container.
These are summarized below:

* ``isaac-cache``: This volume is used to store frequently re-used resources compiled by Omniverse, such as shaders.
* ``isaac-logs``: This volume is used to store logs generated by Omniverse.
* ``isaac-data``: This volume is used to store data generated by Omniverse.
* ``isaac-docs``: This volume is used to store documents generated by Omniverse.
* ``orbit-docs``: This volume is used to store documentation of Orbit when built inside the container.
* ``orbit-logs``: This volume is used to store logs generated by Orbit workflows when ran inside the container.
* ``isaac-cache-kit``: This volume is used to store cached Kit resources (`/isaac-sim/kit/cache` in container)
* ``isaac-cache-ov``: This volume is used to store cached OV resources (`/root/.cache/ov` in container)
* ``isaac-cache-pip``: This volume is used to store cached pip resources (`/root/.cache/pip`` in container)
* ``isaac-cache-gl``: This volume is used to store cached GLCache resources (`/root/.cache/nvidia/GLCache` in container)
* ``isaac-cache-compute``: This volume is used to store cached compute resources (`/root/.nv/ComputeCache` in container)
* ``isaac-logs``: This volume is used to store logs generated by Omniverse. (`/root/.nvidia-omniverse/logs` in container)
* ``isaac-data``: This volume is used to store data generated by Omniverse. (`/root/.local/share/ov/data` in container)
* ``isaac-docs``: This volume is used to store documents generated by Omniverse. (`/root/Documents` in container)
* ``orbit-docs``: This volume is used to store documentation of Orbit when built inside the container. (`/workspace/orbit/docs/_build` in container)
* ``orbit-logs``: This volume is used to store logs generated by Orbit workflows when ran inside the container. (`/workspace/orbit/logs` in container)
* ``orbit-data``: This volume is used to store whatever data users may want to preserve between container runs. (`/workspace/orbit/data_storage` in container)

To view the contents of these volumes, you can use the following command:

.. code:: bash
# list all volumes
docker volume ls
# inspect a specific volume, e.g. isaac-cache
docker volume inspect isaac-cache
# inspect a specific volume, e.g. isaac-cache-kit
docker volume inspect isaac-cache-kit
Invalid mount config for type "bind"
Expand Down
20 changes: 19 additions & 1 deletion source/extensions/omni.isaac.orbit/omni/isaac/orbit/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,25 @@ def __init__(self, **kwargs):
# 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")
# read isaac sim version (this includes build tag, release tag etc.)
# note: we do it once here because it reads the VERSION file from disk and is not expected to change.
from omni.isaac.version import get_version

isaacsim_version = get_version()
if int(isaacsim_version[2]) == 2022:
enable_extension("omni.isaac.urdf")
else:
enable_extension("omni.importer.urdf")
# set the nucleus directory manually to the 2023.1.0 version
# TODO: Remove this once the 2023.1.0 version is released
carb_settings_iface.set_string(
"/persistent/isaac/asset_root/default",
"http://omniverse-content-production.s3-us-west-2.amazonaws.com/Assets/Isaac/2023.1.0",
)
carb_settings_iface.set_string(
"/persistent/isaac/asset_root/nvidia",
"http://omniverse-content-production.s3-us-west-2.amazonaws.com/Assets/Isaac/2023.1.0",
)

# update the global flags
# TODO: Remove all these global flags. We don't need it anymore.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import omni.kit
from omni.isaac.core.materials import PhysicsMaterial
from omni.isaac.core.prims import GeometryPrim
from omni.isaac.version import get_version
from pxr import Gf, PhysxSchema, UsdPhysics, UsdShade


Expand Down Expand Up @@ -96,43 +97,18 @@ def create_ground_plane(
value=Gf.Vec3f(*color),
prev=None,
)
# Change the settings of the sphere light
# Add light source
# By default, the one from Isaac Sim is too dim for large number of environments.
# Warning: This is specific to the default grid plane asset.
light_intensity = kwargs.get("light_intensity", 1e7)
light_radius = kwargs.get("light_radius", 100.0)
# -- light intensity
if light_intensity is not None:
omni.kit.commands.execute(
"ChangeProperty",
prop_path=f"{prim_path}/SphereLight.intensity",
value=light_intensity,
prev=None,
)
# -- light radius
if light_radius is not None:
# set radius of the light
omni.kit.commands.execute(
"ChangeProperty",
prop_path=f"{prim_path}/SphereLight.radius",
value=light_radius,
prev=None,
)
# as a rule of thumb, we set the sphere center 1.5 times
omni.kit.commands.execute(
"ChangeProperty",
prop_path=f"{prim_path}/SphereLight.xformOp:translate",
value=(0.0, 0.0, 1.5 * light_radius),
prev=None,
)
# -- ambient light
ambient_light = kwargs.get("ambient_light", True)
if ambient_light:
prim_utils.create_prim(
f"{prim_path}/AmbientLight",
"DistantLight",
attributes={"intensity": 600.0},
)
# check isaacsim version to determine the attribute name
attributes = {"intensity": 600.0}
isaacsim_version = get_version()
if int(isaacsim_version[2]) > 2022:
attributes = {f"inputs:{k}": v for k, v in attributes.items()}
# create light prim
prim_utils.create_prim(f"{prim_path}/AmbientLight", "DistantLight", attributes=attributes)


def move_nested_prims(source_ns: str, target_ns: str):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

from dataclasses import MISSING

from omni.isaac.orbit.controllers import DifferentialIKControllerCfg
from omni.isaac.orbit.managers.action_manager import ActionTerm, ActionTermCfg
from omni.isaac.orbit.utils import configclass
from omni.isaac.orbit.controllers import DifferentialIKControllerCfg

from . import binary_joint_actions, joint_actions, non_holonomic_actions, task_space_actions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,17 @@ def _prepare_terms(self):
raise TypeError(
f"Configuration for the term '{term_name}' is not of type RewardTermCfg. Received '{type(term_cfg)}'."
)
# check for valid weight type
if not isinstance(term_cfg.weight, (float, int)):
raise TypeError(
f"Weight for the term '{term_name}' is not of type float or int. Received '{type(term_cfg.weight)}'."
)
# resolve common parameters
self._resolve_common_term_cfg(term_name, term_cfg, min_argc=1)
# remove zero scales and multiply non-zero ones by dt
# note: we multiply weights by dt to make them agnostic to control decimation
if term_cfg.weight == 0:
term_cfg.weight = float(term_cfg.weight)
if term_cfg.weight == 0.0:
continue
# add function to list
self._term_names.append(term_name)
Expand Down
Loading

0 comments on commit 588bd36

Please sign in to comment.