Skip to content

Commit

Permalink
Merge branch 'og-develop' into fix-primitives-2
Browse files Browse the repository at this point in the history
  • Loading branch information
cgokmen authored Mar 16, 2024
2 parents acd2b2e + 4c5df20 commit db89187
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 66 deletions.
20 changes: 8 additions & 12 deletions omnigibson/objects/light_object.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from omnigibson.utils.sim_utils import meets_minimum_isaac_version
import omnigibson as og
import omnigibson.lazy as lazy
from omnigibson.objects.stateful_object import StatefulObject
Expand Down Expand Up @@ -156,7 +155,7 @@ def radius(self):
Returns:
float: radius for this light
"""
return self._light_link.get_attribute("inputs:radius" if meets_minimum_isaac_version("2023.0.0") else "radius")
return self._light_link.get_attribute("inputs:radius")

@radius.setter
def radius(self, radius):
Expand All @@ -166,7 +165,7 @@ def radius(self, radius):
Args:
radius (float): radius to set
"""
self._light_link.set_attribute("inputs:radius" if meets_minimum_isaac_version("2023.0.0") else "radius", radius)
self._light_link.set_attribute("inputs:radius", radius)

@property
def intensity(self):
Expand All @@ -176,8 +175,7 @@ def intensity(self):
Returns:
float: intensity for this light
"""
return self._light_link.get_attribute(
"inputs:intensity" if meets_minimum_isaac_version("2023.0.0") else "intensity")
return self._light_link.get_attribute("inputs:intensity")

@intensity.setter
def intensity(self, intensity):
Expand All @@ -188,7 +186,7 @@ def intensity(self, intensity):
intensity (float): intensity to set
"""
self._light_link.set_attribute(
"inputs:intensity" if meets_minimum_isaac_version("2023.0.0") else "intensity",
"inputs:intensity",
intensity)

@property
Expand All @@ -199,8 +197,7 @@ def color(self):
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"))
return tuple(float(x) for x in self._light_link.get_attribute("inputs:color"))

@color.setter
def color(self, color):
Expand All @@ -211,7 +208,7 @@ def color(self, color):
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",
"inputs:color",
lazy.pxr.Gf.Vec3f(color))

@property
Expand All @@ -222,8 +219,7 @@ def texture_file_path(self):
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"))
return str(self._light_link.get_attribute("inputs:texture:file"))

@texture_file_path.setter
def texture_file_path(self, texture_file_path):
Expand All @@ -234,7 +230,7 @@ def texture_file_path(self, texture_file_path):
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",
"inputs:texture:file",
lazy.pxr.Sdf.AssetPath(texture_file_path))


Expand Down
11 changes: 4 additions & 7 deletions omnigibson/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def _launch_app():
with launch_context(None):
app = lazy.omni.isaac.kit.SimulationApp(config_kwargs)

assert meets_minimum_isaac_version("2023.1.1"), "This version of OmniGibson supports Isaac Sim 2023.1.1 and above. Please update Isaac Sim."

# Omni overrides the global logger to be DEBUG, which is very annoying, so we re-override it to the default WARN
# TODO: Remove this once omniverse fixes it
logging.getLogger().setLevel(logging.WARNING)
Expand Down Expand Up @@ -314,11 +316,7 @@ def _set_physics_engine_settings(self):
# default collide with each other, and modify settings for speed optimization
self._physics_context.set_invert_collision_group_filter(False)
self._physics_context.enable_ccd(gm.ENABLE_CCD)

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)
self._physics_context.enable_fabric(gm.ENABLE_FLATCACHE)

# Enable GPU dynamics based on whether we need omni particles feature
if gm.USE_GPU_DYNAMICS:
Expand Down Expand Up @@ -1219,8 +1217,7 @@ def _open_new_stage(self):

# Clear physics context
self._physics_context = None
if meets_minimum_isaac_version("2023.0.0"):
self._physx_fabric_interface = None
self._physx_fabric_interface = None

# Create world prim
self.stage.DefinePrim("/World", "Xform")
Expand Down
12 changes: 3 additions & 9 deletions omnigibson/utils/control_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import numpy as np
from numba import jit
import omnigibson.utils.transform_utils as T
from omnigibson.utils.sim_utils import meets_minimum_isaac_version

class FKSolver:
"""
Expand Down Expand Up @@ -116,14 +115,9 @@ def solve(
self.config.position_tolerance = tolerance_pos
self.config.orientation_tolerance = 100.0 if target_quat is None else tolerance_quat

if meets_minimum_isaac_version("2023.0.0"):
self.config.ccd_position_weight = weight_pos
self.config.ccd_orientation_weight = 0.0 if target_quat is None else weight_quat
self.config.max_num_descents = max_iterations
else:
self.config.position_weight = weight_pos
self.config.orientation_weight = 0.0 if target_quat is None else weight_quat
self.config.max_iterations_per_descent = max_iterations
self.config.ccd_position_weight = weight_pos
self.config.ccd_orientation_weight = 0.0 if target_quat is None else weight_quat
self.config.max_num_descents = max_iterations

# Compute target joint positions
ik_results = lazy.lula.compute_ik_ccd(self.kinematics, ik_target_pose, self.eef_name, self.config)
Expand Down
40 changes: 2 additions & 38 deletions omnigibson/utils/deprecated_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,42 +77,7 @@ def __init__(self, prim_type: str, **kwargs):
assert isinstance(self._evaluator_class, type)


class Utils2022(OmniUtils):
"""
Subclass that overrides a specific function within Omni's Utils class to fix a bug
"""
def create_material(self, name):
# TODO: THIS IS THE ONLY LINE WE CHANGE! "/" SHOULD BE ""
material_path = ""
default_prim = self.stage.GetDefaultPrim()
if default_prim:
material_path = default_prim.GetPath().pathString

if not self.stage.GetPrimAtPath(material_path + "/Looks"):
self.stage.DefinePrim(material_path + "/Looks", "Scope")
material_path += "/Looks/" + name
material_path = ou.get_stage_next_free_path(
self.stage, material_path, False
)
material = UsdShade.Material.Define(self.stage, material_path)

shader_path = material_path + "/Shader"
shader = UsdShade.Shader.Define(self.stage, shader_path)

# Update Neuraylib MDL search paths
import omni.particle.system.core as core
core.update_mdl_search_paths()

shader.SetSourceAsset(name + ".mdl", "mdl")
shader.SetSourceAssetSubIdentifier(name, "mdl")
shader.GetImplementationSourceAttr().Set(UsdShade.Tokens.sourceAsset)
shader.CreateOutput("out", Sdf.ValueTypeNames.Token)
material.CreateSurfaceOutput().ConnectToSource(shader, "out")

return [material_path]


class Utils2023(OmniUtils):
class Utils(OmniUtils):
def create_material(self, name):
material_url = carb.settings.get_settings().get("/exts/omni.particle.system.core/material")

Expand Down Expand Up @@ -143,8 +108,7 @@ class Core(OmniCore):
"""
def __init__(self, popup_callback: Callable[[str], None], particle_system_name: str):
self._popup_callback = popup_callback
from omnigibson.utils.sim_utils import meets_minimum_isaac_version
self.utils = Utils2023() if meets_minimum_isaac_version("2023.0.0") else Utils2022()
self.utils = Utils()
self.context = ou.get_context()
self.stage = self.context.get_stage()
self.selection = self.context.get_selection()
Expand Down

0 comments on commit db89187

Please sign in to comment.