Address comments

This commit is contained in:
Hang Yin 2024-06-25 16:15:28 -07:00
parent 8bcb38d72e
commit ad825c6483
9 changed files with 29 additions and 35 deletions

View File

@ -3,7 +3,6 @@ from enum import IntEnum
import numpy as np
from omnigibson.utils.constants import MAGIC_DEFAULT
from omnigibson.utils.python_utils import Recreatable, Registerable, Serializable, assert_valid_key, classproperty
# Global dicts that will contain mappings
@ -126,13 +125,17 @@ class BaseController(Serializable, Registerable, Recreatable):
self._command_input_transform = None
# Standardize command input / output limits to be (min_array, max_array)
command_input_limits = (-1.0, 1.0) if MAGIC_DEFAULT == command_input_limits else command_input_limits
command_input_limits = (
(-1.0, 1.0)
if type(command_input_limits) == str and command_input_limits == "default"
else command_input_limits
)
command_output_limits = (
(
np.array(self._control_limits[self.control_type][0])[self.dof_idx],
np.array(self._control_limits[self.control_type][1])[self.dof_idx],
)
if MAGIC_DEFAULT == command_output_limits
if type(command_input_limits) == str and command_input_limits == "default"
else command_output_limits
)
self._command_input_limits = (

View File

@ -1,7 +1,6 @@
import numpy as np
from omnigibson.controllers import ControlType, LocomotionController
from omnigibson.utils.constants import MAGIC_DEFAULT
class DifferentialDriveController(LocomotionController):
@ -55,7 +54,7 @@ class DifferentialDriveController(LocomotionController):
self._wheel_axle_halflength = wheel_axle_length / 2.0
# If we're using default command output limits, map this to maximum linear / angular velocities
if MAGIC_DEFAULT == command_output_limits:
if type(command_output_limits) == str and command_output_limits == "default":
min_vels = control_limits["velocity"][0][dof_idx]
assert (
min_vels[0] == min_vels[1]

View File

@ -4,7 +4,6 @@ import omnigibson.utils.transform_utils as T
from omnigibson.controllers import ControlType, ManipulationController
from omnigibson.controllers.joint_controller import JointController
from omnigibson.macros import create_module_macros, gm
from omnigibson.utils.constants import MAGIC_DEFAULT
from omnigibson.utils.control_utils import IKSolver
from omnigibson.utils.processing_utils import MovingAverageFilter
from omnigibson.utils.python_utils import assert_valid_key
@ -154,7 +153,7 @@ class InverseKinematicsController(JointController, ManipulationController):
# The output orientation limits are also set to be values assuming delta commands, so those are updated too
if self.mode == "pose_absolute_ori":
if command_input_limits is not None:
if MAGIC_DEFAULT == command_input_limits:
if type(command_input_limits) == str and command_input_limits == "default":
command_input_limits = [
[-1.0, -1.0, -1.0, -np.pi, -np.pi, -np.pi],
[1.0, 1.0, 1.0, np.pi, np.pi, np.pi],
@ -163,7 +162,7 @@ class InverseKinematicsController(JointController, ManipulationController):
command_input_limits[0][3:] = -np.pi
command_input_limits[1][3:] = np.pi
if command_output_limits is not None:
if MAGIC_DEFAULT == command_output_limits:
if type(command_output_limits) == str and command_output_limits == "default":
command_output_limits = [
[-1.0, -1.0, -1.0, -np.pi, -np.pi, -np.pi],
[1.0, 1.0, 1.0, np.pi, np.pi, np.pi],

View File

@ -9,7 +9,6 @@ from omnigibson.controllers import (
ManipulationController,
)
from omnigibson.macros import create_module_macros
from omnigibson.utils.constants import MAGIC_DEFAULT
from omnigibson.utils.python_utils import assert_valid_key
# Create settings for this module
@ -102,7 +101,7 @@ class JointController(LocomotionController, ManipulationController, GripperContr
# When in delta mode, it doesn't make sense to infer output range using the joint limits (since that's an
# absolute range and our values are relative). So reject the default mode option in that case.
assert not (
self._use_delta_commands and MAGIC_DEFAULT == command_output_limits
self._use_delta_commands and type(command_output_limits) == str and command_output_limits == "default"
), "Cannot use 'default' command output limits in delta commands mode of JointController. Try None instead."
# Run super init

View File

@ -3,7 +3,6 @@ import numpy as np
import omnigibson.utils.transform_utils as T
from omnigibson.controllers import ControlType, GripperController, IsGraspingState
from omnigibson.macros import create_module_macros
from omnigibson.utils.constants import MAGIC_DEFAULT
from omnigibson.utils.python_utils import assert_valid_key
VALID_MODES = {

View File

@ -3,7 +3,6 @@ from numba import jit
import omnigibson.utils.transform_utils as T
from omnigibson.controllers import ControlType, ManipulationController
from omnigibson.utils.constants import MAGIC_DEFAULT
from omnigibson.utils.control_utils import orientation_error
from omnigibson.utils.processing_utils import MovingAverageFilter
from omnigibson.utils.python_utils import assert_valid_key, nums2array
@ -158,7 +157,7 @@ class OperationalSpaceController(ManipulationController):
self.mode = mode
if self.mode == "pose_absolute_ori":
if command_input_limits is not None:
if MAGIC_DEFAULT == command_input_limits:
if type(command_input_limits) == str and command_input_limits == "default":
command_input_limits = [
[-1.0, -1.0, -1.0, -np.pi, -np.pi, -np.pi],
[1.0, 1.0, 1.0, np.pi, np.pi, np.pi],
@ -167,7 +166,7 @@ class OperationalSpaceController(ManipulationController):
command_input_limits[0][3:] = -np.pi
command_input_limits[1][3:] = np.pi
if command_output_limits is not None:
if MAGIC_DEFAULT == command_output_limits:
if type(command_output_limits) == str and command_output_limits == "default":
command_output_limits = [
[-1.0, -1.0, -1.0, -np.pi, -np.pi, -np.pi],
[1.0, 1.0, 1.0, np.pi, np.pi, np.pi],

View File

@ -596,14 +596,16 @@ class VisionSensor(BaseSensor):
self._viewport.viewport_api.set_texture_resolution((width, height))
# Also update render product and update all annotators
old_render_product = self._render_product
new_render_product = lazy.omni.replicator.core.create.render_product(self.prim_path, (width, height))
for annotator in self._annotators.values():
annotator.detach([old_render_product.path])
annotator.attach([new_render_product])
annotator.detach([self._render_product.path])
old_render_product.destroy()
self._render_product = new_render_product
self._render_product.destroy()
self._render_product = lazy.omni.replicator.core.create.render_product(
self.prim_path, (width, height), force_new=True
)
for annotator in self._annotators.values():
annotator.attach([self._render_product])
# Requires 3 updates to propagate changes
for i in range(3):
@ -629,14 +631,16 @@ class VisionSensor(BaseSensor):
self._viewport.viewport_api.set_texture_resolution((width, height))
# Also update render product and update all annotators
old_render_product = self._render_product
new_render_product = lazy.omni.replicator.core.create.render_product(self.prim_path, (width, height))
for annotator in self._annotators.values():
annotator.detach([old_render_product.path])
annotator.attach([new_render_product])
annotator.detach([self._render_product.path])
old_render_product.destroy()
self._render_product = new_render_product
self._render_product.destroy()
self._render_product = lazy.omni.replicator.core.create.render_product(
self.prim_path, (width, height), force_new=True
)
for annotator in self._annotators.values():
annotator.attach([self._render_product])
# Requires 3 updates to propagate changes
for i in range(3):

View File

@ -18,14 +18,6 @@ MAX_CLASS_COUNT = np.iinfo(np.uint32).max
MAX_VIEWER_SIZE = 2048
class strWithCompare(str):
def __eq__(self, other):
return isinstance(other, str) and str.__eq__(self, other)
MAGIC_DEFAULT = strWithCompare("default")
class ViewerMode(IntEnum):
NAVIGATION = 0
MANIPULATION = 1

View File

@ -352,7 +352,7 @@ class SerializableRegistry(Registry, Serializable):
# loading will be skipped.
for obj in self.objects:
if obj.name not in state:
# log.warning(f"Object '{obj.name}' is not in the state dict to load from. Skip loading its state.")
log.warning(f"Object '{obj.name}' is not in the state dict to load from. Skip loading its state.")
continue
obj.load_state(state[obj.name], serialized=False)