Skip to content

Commit

Permalink
Merge pull request #258 from StanfordVL/isaac-2023-1-0-compat
Browse files Browse the repository at this point in the history
Support Isaac Sim 2023.1.0
  • Loading branch information
cgokmen authored Aug 24, 2023
2 parents ac8113e + 88351a4 commit ca0265f
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 26 deletions.
2 changes: 1 addition & 1 deletion omnigibson/controllers/controller_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections import Iterable
from collections.abc import Iterable
from enum import IntEnum

import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/objects/controllable_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from copy import deepcopy
import numpy as np
import gym
from collections import Iterable
from collections.abc import Iterable
import omnigibson as og
from omnigibson.objects.object_base import BaseObject
from omnigibson.controllers import create_controller
Expand Down
61 changes: 56 additions & 5 deletions omnigibson/objects/light_object.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pxr import UsdLux
from omnigibson.utils.sim_utils import meets_minimum_isaac_version
from pxr import UsdLux, Sdf, Gf
import omnigibson as og
from omni.isaac.core.utils.stage import get_current_stage
from omnigibson.objects.stateful_object import StatefulObject
Expand Down Expand Up @@ -167,22 +168,72 @@ def radius(self, radius):
@property
def intensity(self):
"""
Gets this joint's intensity
Gets this light's intensity
Returns:
float: intensity for this light
"""
return self._light_link.get_attribute("intensity")
return self._light_link.get_attribute(
"inputs:intensity" if meets_minimum_isaac_version("2023.0.0") else "intensity")

@intensity.setter
def intensity(self, intensity):
"""
Sets this joint's intensity
Sets this light's intensity
Args:
intensity (float): intensity to set
"""
self._light_link.set_attribute("intensity", intensity)
self._light_link.set_attribute(
"inputs:intensity" if meets_minimum_isaac_version("2023.0.0") else "intensity",
intensity)

@property
def color(self):
"""
Gets this light's color
Returns:
float: color for this light
"""
return tuple(float(x) for x in self._light_link.get_attribute(
"inputs:color" if meets_minimum_isaac_version("2023.0.0") else "color"))

@color.setter
def color(self, color):
"""
Sets this light's color
Args:
color ([float, float, float]): color to set, each value in range [0, 1]
"""
self._light_link.set_attribute(
"inputs:color" if meets_minimum_isaac_version("2023.0.0") else "color",
Gf.Vec3f(color))

@property
def texture_file_path(self):
"""
Gets this light's texture file path. Only valid for dome lights.
Returns:
str: texture file path for this light
"""
return str(self._light_link.get_attribute(
"inputs:texture:file" if meets_minimum_isaac_version("2023.0.0") else "texture:file"))

@texture_file_path.setter
def texture_file_path(self, texture_file_path):
"""
Sets this light's texture file path. Only valid for dome lights.
Args:
texture_file_path (str): path of texture file that should be used for this light
"""
self._light_link.set_attribute(
"inputs:texture:file" if meets_minimum_isaac_version("2023.0.0") else "texture:file",
Sdf.AssetPath(texture_file_path))


def _create_prim_with_same_kwargs(self, prim_path, name, load_config):
# Add additional kwargs (fit_avg_dim_volume and bounding_box are already captured in load_config)
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/objects/object_base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABCMeta
import numpy as np
from collections import Iterable
from collections.abc import Iterable

import omnigibson as og
from omnigibson.macros import create_module_macros, gm
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/prims/joint_prim.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections import Iterable
from collections.abc import Iterable
from pxr import Gf, Usd, Sdf, UsdGeom, UsdShade, UsdPhysics, PhysxSchema
from omni.isaac.dynamic_control import _dynamic_control
from omni.isaac.core.utils.rotations import gf_quat_to_np_array
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/prims/xform_prim.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections import Iterable
from collections.abc import Iterable
from pxr import Gf, Usd, UsdGeom, UsdShade, UsdPhysics
from omni.isaac.core.utils.rotations import gf_quat_to_np_array
from omni.isaac.core.utils.prims import (
Expand Down
6 changes: 2 additions & 4 deletions omnigibson/scenes/scene_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from omnigibson.systems.system_base import SYSTEM_REGISTRY, clear_all_systems, get_system
from omnigibson.objects.light_object import LightObject
from omnigibson.robots.robot_base import m as robot_macros
from pxr import Sdf, Gf

# Create module logger
log = create_module_logger(module_name=__name__)
Expand Down Expand Up @@ -184,9 +183,8 @@ def _load(self):
fixed_base=True,
)
og.sim.import_object(self._skybox, register=False)
light_prim = self._skybox.light_link.prim
light_prim.GetAttribute("color").Set(Gf.Vec3f(1.07, 0.85, 0.61))
light_prim.GetAttribute("texture:file").Set(Sdf.AssetPath(m.DEFAULT_SKYBOX_TEXTURE))
self._skybox.color = (1.07, 0.85, 0.61)
self._skybox.texture_file_path = m.DEFAULT_SKYBOX_TEXTURE

def _load_objects_from_scene_file(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/sensors/scan_sensor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cv2
import numpy as np
from collections import Iterable
from collections.abc import Iterable

from transforms3d.quaternions import quat2mat

Expand Down
7 changes: 6 additions & 1 deletion omnigibson/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from omnigibson.utils.constants import LightingMode
from omnigibson.utils.config_utils import NumpyEncoder
from omnigibson.utils.python_utils import clear as clear_pu, create_object_from_init_info, Serializable
from omnigibson.utils.sim_utils import meets_minimum_isaac_version
from omnigibson.utils.usd_utils import clear as clear_uu, BoundingBoxAPI, FlatcacheAPI, RigidContactAPI
from omnigibson.utils.ui_utils import CameraMover, disclaimer, create_module_logger, suppress_omni_log
from omnigibson.scenes import Scene
Expand Down Expand Up @@ -202,7 +203,11 @@ def _set_physics_engine_settings(self):
# collide with each other, and modify settings for speed optimization
self._physics_context.set_invert_collision_group_filter(True)
self._physics_context.enable_ccd(gm.ENABLE_CCD)
self._physics_context.enable_flatcache(gm.ENABLE_FLATCACHE)

if meets_minimum_isaac_version("2023.0.0"):
self._physics_context.enable_fabric(gm.ENABLE_FLATCACHE)
else:
self._physics_context.enable_flatcache(gm.ENABLE_FLATCACHE)

# Enable GPU dynamics based on whether we need omni particles feature
if gm.USE_GPU_DYNAMICS:
Expand Down
4 changes: 2 additions & 2 deletions omnigibson/utils/config_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import collections
import collections.abc
import json
import os
import numpy as np
Expand All @@ -19,7 +19,7 @@ def parse_config(config):
Returns:
dict: Parsed config
"""
if isinstance(config, collections.Mapping):
if isinstance(config, collections.abc.Mapping):
return config
else:
assert isinstance(config, str)
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/utils/python_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import re
from abc import ABCMeta
from copy import deepcopy
from collections import Iterable
from collections.abc import Iterable
from functools import wraps
from importlib import import_module

Expand Down
2 changes: 1 addition & 1 deletion omnigibson/utils/registry_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
from inspect import isclass
import numpy as np
from collections import Iterable
from collections.abc import Iterable
from omnigibson.macros import create_module_macros
from omnigibson.utils.python_utils import Serializable, SerializableNonInstance, UniquelyNamed
from omnigibson.utils.ui_utils import create_module_logger
Expand Down
9 changes: 8 additions & 1 deletion omnigibson/utils/sim_utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import numpy as np
from collections import Iterable, namedtuple
from collections import namedtuple
from collections.abc import Iterable

import omnigibson as og
from omnigibson.macros import gm
from omnigibson.utils import python_utils
import omnigibson.utils.transform_utils as T
from omnigibson.utils.usd_utils import BoundingBoxAPI
from omni.physx import get_physx_simulation_interface
from omni.isaac.core.utils.prims import is_prim_ancestral, get_prim_type_name, is_prim_no_delete
from omni.isaac.version import get_version
from omnigibson.utils.ui_utils import create_module_logger

# Create module logger
Expand Down Expand Up @@ -351,3 +354,7 @@ def land_object(obj, pos, quat=None, z_offset=None):
log.warning(f"Object {obj.name} failed to land.")

obj.keep_still()


def meets_minimum_isaac_version(minimum_version):
return python_utils.meets_minimum_version(get_version()[0], minimum_version)
2 changes: 1 addition & 1 deletion omnigibson/utils/usd_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import math
from collections import Iterable
from collections.abc import Iterable
import os

import omni.usd
Expand Down
8 changes: 6 additions & 2 deletions scripts/setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ echo:
echo Using %conda_name% as the conda environment name
echo:

:: Create a conda environment with python 3.7
call conda create -y -n %conda_name% python=3.7 || goto :error
:: Get Python version from Isaac Sim
FOR /F "tokens=*" %%g IN ('%ISAAC_SIM_PATH%\python.bat -c "import platform; print(platform.python_version())"') do (SET ISAAC_PYTHON_VERSION=%%g)
echo Using Python version %ISAAC_PYTHON_VERSION% matching your current Isaac Sim version

:: Create a conda environment with the appropriate python version
call conda create -y -n %conda_name% python=%ISAAC_PYTHON_VERSION% || goto :error
call conda activate %conda_name% || goto :error

:: We add some preprocessing information so that the Isaac Sim paths are linked to this environment upon startup
Expand Down
8 changes: 6 additions & 2 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ read -p "If you want to use a different name, please type in here (press enter t
conda_name=${conda_name:-omnigibson}
echo -e "\nUsing $conda_name as the conda environment name\n"

# Create a conda environment with python 3.7
# Get Python version from Isaac Sim
ISAAC_PYTHON_VERSION=$(${ISAAC_SIM_PATH}/python -c "import platform; print(platform.python_version())")
echo Using Python version $ISAAC_PYTHON_VERSION[0m matching your current Isaac Sim version

# Create a conda environment with the appropriate python version
source $(conda info --base)/etc/profile.d/conda.sh
conda create -y -n $conda_name python=3.7
conda create -y -n $conda_name python=${ISAAC_PYTHON_VERSION}

# Now activate the omnigibson environment
conda activate $conda_name
Expand Down

0 comments on commit ca0265f

Please sign in to comment.