Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to isaac sim 4.2 & VR #906

Draft
wants to merge 78 commits into
base: og-develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
4c9d1e1
Upgrade to isaac sim 4.2
hang-yin Sep 25, 2024
13fe889
Add version 4.2 to KIT_FILES
hang-yin Sep 25, 2024
36dee3b
Merge branch 'og-develop' of https://github.com/StanfordVL/OmniGibson…
hang-yin Oct 2, 2024
5c2d25a
Merge branch 'og-develop' of https://github.com/StanfordVL/OmniGibson…
hang-yin Oct 3, 2024
5cddc03
Fix ObjectsInFOVOfRobot test
hang-yin Oct 7, 2024
14051b2
Isaac 4 2 update
hang-yin Oct 7, 2024
c303a0b
Deprecate projection emitter
hang-yin Oct 7, 2024
ffdce57
Retrieve default shader input from shader node
hang-yin Oct 7, 2024
1e13d9e
Merge branch 'og-develop' into isaac_4_2
hang-yin Oct 7, 2024
aab3b3b
Unbreak ObjectsInFOVOfRobot test
hang-yin Oct 7, 2024
1e04111
Fix transform util
hang-yin Oct 7, 2024
8a7f3af
Fix material prim shader input bug
hang-yin Oct 8, 2024
c8cf5b9
Rename shader_input_names_by_type
hang-yin Oct 8, 2024
99f0999
Update robot pictures
hang-yin Oct 8, 2024
c210870
Mist effect initial implementation
hang-yin Oct 23, 2024
d03bfd4
VR scene tour demo without robot control
hang-yin Oct 31, 2024
4aeed8f
VR robot control with A1 demo
hang-yin Oct 31, 2024
97e85cc
Small infra changes for VR teleop
hang-yin Oct 31, 2024
552d87c
Teleop utils refactor, WIP
hang-yin Oct 31, 2024
90efba5
Update 4-2-0 kit file to include vr/xr extension
hang-yin Oct 31, 2024
2e6e63a
Merge branch 'isaac_4_2' of https://github.com/StanfordVL/OmniGibson …
hang-yin Nov 4, 2024
bc74a5c
WIP
hang-yin Nov 27, 2024
8f41145
Merge branch 'asset-conversion' of https://github.com/StanfordVL/Omni…
hang-yin Nov 27, 2024
bf3c2f9
Minor updates
hang-yin Dec 2, 2024
cfb5f30
Merge branch 'isaac_4_2' of https://github.com/StanfordVL/OmniGibson …
hang-yin Dec 2, 2024
f30bf9e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 2, 2024
397a34d
Clean up vr utils
hang-yin Dec 3, 2024
06d1578
refactor backend to use np for better single-threaded efficiency
cremebrule Dec 3, 2024
38b2a47
fix small typo
cremebrule Dec 3, 2024
429cfeb
update setup requirements
cremebrule Dec 3, 2024
0d808f2
Merge branch 'feat/np-opt' of https://github.com/StanfordVL/OmniGibso…
hang-yin Dec 4, 2024
8fa44a0
cache indexing values for better efficiency
cremebrule Dec 4, 2024
5d3bce5
improve control loop efficiency, cache relative tf computations
cremebrule Dec 4, 2024
54a351d
Allow headset to follow xformprim
hang-yin Dec 5, 2024
e73e1ab
Merge branch 'feat/np-opt' of https://github.com/StanfordVL/OmniGibso…
hang-yin Dec 5, 2024
6787df3
optimize controller computation functions
cremebrule Dec 5, 2024
692df78
cache properties that should not change during runtime
cremebrule Dec 5, 2024
d092a6f
optimize np numba transform functions
cremebrule Dec 5, 2024
d8d009e
Merge branch 'feat/np-opt' of https://github.com/StanfordVL/OmniGibso…
hang-yin Dec 5, 2024
20d4da2
Numpy optimization and data collection wrapper bug fixes
hang-yin Dec 9, 2024
4377a57
Allow VR free head orientation motion; optimize VR for data collection
hang-yin Dec 9, 2024
4ef6f4d
Merge branch 'asset-conversion' into feat/np-opt
cremebrule Dec 12, 2024
69df439
refactor controller backend and general compute backend
cremebrule Dec 12, 2024
3b8d114
update filters to use compute backend
cremebrule Dec 12, 2024
e45e719
fix controller bugs
cremebrule Dec 12, 2024
e9219c2
fix proprioception dict generation
cremebrule Dec 12, 2024
50d390a
fix holonomic robot pose setting
cremebrule Dec 12, 2024
fd07d8a
fix controllable object and filters state de/serialization
cremebrule Dec 12, 2024
9401922
make np tf use numba
cremebrule Dec 12, 2024
920d161
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 12, 2024
5121aa5
ensure actions and control dict is handled properly externally
cremebrule Dec 12, 2024
60d65ab
Merge remote-tracking branch 'origin/feat/np-opt' into feat/np-opt
cremebrule Dec 12, 2024
8d6f25f
fix control torch reference
cremebrule Dec 12, 2024
1dd3b28
Merge branch 'asset-conversion' into feat/np-opt
cremebrule Dec 12, 2024
d4553eb
Merge branch 'asset-conversion' into feat/np-opt
cremebrule Dec 12, 2024
f73f9f0
Merge branch 'asset-conversion' into feat/np-opt
cremebrule Dec 12, 2024
64fab4f
Merge branch 'asset-conversion' into feat/np-opt
cremebrule Dec 12, 2024
62d08b9
use compute backend for filter product
cremebrule Dec 12, 2024
5d672a6
use 0-dim command for null joint controller
cremebrule Dec 12, 2024
deccf82
Add view angle limits to VR
hang-yin Dec 12, 2024
0fca8d6
improve curobo test determinism
cremebrule Dec 12, 2024
c83772d
make collision activation settable for better reproducability in curo…
cremebrule Dec 12, 2024
11b9876
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 12, 2024
8268247
Merge branch 'asset-conversion' into feat/np-opt
cremebrule Dec 12, 2024
a546d45
Merge remote-tracking branch 'origin/feat/np-opt' into feat/np-opt
cremebrule Dec 12, 2024
b606001
fix IK controller arg parsing
cremebrule Dec 12, 2024
474aa0d
update comments external -> custom dataset
cremebrule Dec 12, 2024
ee78e94
Merge branch 'asset-conversion' into feat/np-opt
cremebrule Dec 12, 2024
04c37c5
update version and remove extraneous np import
cremebrule Dec 12, 2024
3e015f7
Merge branch 'og-develop' into feat/np-opt
cremebrule Dec 12, 2024
e31c12a
make urdf paths relative during custom asset import
cremebrule Dec 13, 2024
6275ab9
handle vision sensor cleanup properly
cremebrule Dec 13, 2024
42e1d9d
fix default command output behavior for joint controllers
cremebrule Dec 14, 2024
40cc3f0
Merge branch 'og-develop' of https://github.com/StanfordVL/OmniGibson…
hang-yin Dec 17, 2024
f455421
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 17, 2024
ffa72bc
Merge branch 'feat/np-opt' of https://github.com/StanfordVL/OmniGibso…
hang-yin Dec 18, 2024
1c57085
Tiny bug fixes
hang-yin Dec 18, 2024
7d02e86
Merge branch 'isaac_4_2' of https://github.com/StanfordVL/OmniGibson …
hang-yin Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 95 additions & 36 deletions omnigibson/controllers/ik_controller.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import math
from collections.abc import Iterable
from omnigibson.controllers.controller_base import _ControllerBackend, _ControllerTorchBackend, _ControllerNumpyBackend
from omnigibson.controllers.controller_base import _controller_backend as cb

from omnigibson.controllers import ControlType, ManipulationController
Expand Down Expand Up @@ -270,8 +271,8 @@ def _update_goal(self, command, control_dict):
target_pos, target_quat = self.workspace_pose_limiter(target_pos, target_quat, control_dict)

goal_dict = dict(
target_pos=target_pos,
target_quat=target_quat,
target_pos=cb.as_float32(target_pos),
target_ori_mat=cb.as_float32(cb.T.quat2mat(target_quat)),
)

return goal_dict
Expand All @@ -285,7 +286,7 @@ def compute_control(self, goal_dict, control_dict):
goal_dict (Dict[str, Any]): dictionary that should include any relevant keyword-mapped
goals necessary for controller computation. Must include the following keys:
target_pos: robot-frame (x,y,z) desired end effector position
target_quat: robot-frame (x,y,z,w) desired end effector quaternion orientation
target_ori_mat: robot-frame desired end effector quaternion orientation matrix
control_dict (Dict[str, Any]): dictionary that should include any relevant keyword-mapped
states necessary for controller computation. Must include the following keys:
joint_position: Array of current joint positions
Expand All @@ -299,37 +300,23 @@ def compute_control(self, goal_dict, control_dict):
Returns:
Array[float]: outputted (non-clipped!) velocity control signal to deploy
"""
# Grab important info from control dict
pos_relative = control_dict[f"{self.task_name}_pos_relative"]
quat_relative = control_dict[f"{self.task_name}_quat_relative"]
target_pos = goal_dict["target_pos"]
target_quat = goal_dict["target_quat"]

# Calculate and return IK-backed out joint angles
current_joint_pos = control_dict["joint_position"][self.dof_idx]

# If the delta is really small, we just keep the current joint position. This avoids joint
# drift caused by IK solver inaccuracy even when zero delta actions are provided.
if cb.allclose(pos_relative, target_pos, atol=1e-4) and cb.allclose(quat_relative, target_quat, atol=1e-4):
target_joint_pos = current_joint_pos
else:
# Compute the pose error. Note that this is computed NOT in the EEF frame but still
# in the base frame.
pos_err = target_pos - pos_relative
ori_err = cb.T.orientation_error(cb.T.quat2mat(target_quat), cb.T.quat2mat(quat_relative))
err = cb.cat([pos_err, ori_err])

# Use the jacobian to compute a local approximation
j_eef = control_dict[f"{self.task_name}_jacobian_relative"][:, self.dof_idx]
j_eef_pinv = cb.pinv(j_eef)
delta_j = j_eef_pinv @ err
target_joint_pos = current_joint_pos + delta_j

# Clip values to be within the joint limits
target_joint_pos = target_joint_pos.clip(
min=self._control_limits[ControlType.get_type("position")][0][self.dof_idx],
max=self._control_limits[ControlType.get_type("position")][1][self.dof_idx],
)
q = control_dict["joint_position"][self.dof_idx]
j_eef = control_dict[f"{self.task_name}_jacobian_relative"][:, self.dof_idx]
ee_pos = control_dict[f"{self.task_name}_pos_relative"]
ee_quat = control_dict[f"{self.task_name}_quat_relative"]

# Calculate desired joint positions
target_joint_pos = cb.compute_ik_qpos(
q=q,
j_eef=j_eef,
ee_pos=cb.as_float32(ee_pos),
ee_mat=cb.as_float32(cb.T.quat2mat(ee_quat)),
goal_pos=goal_dict["target_pos"],
goal_ori_mat=goal_dict["target_ori_mat"],
q_lower_limit=self._control_limits[ControlType.get_type("position")][0][self.dof_idx],
q_upper_limit=self._control_limits[ControlType.get_type("position")][1][self.dof_idx],
)

# Optionally pass through smoothing filter for better stability
if self.control_filter is not None:
Expand All @@ -340,9 +327,13 @@ def compute_control(self, goal_dict, control_dict):

def compute_no_op_goal(self, control_dict):
# No-op is maintaining current pose
target_pos = cb.copy(control_dict[f"{self.task_name}_pos_relative"])
target_quat = cb.copy(control_dict[f"{self.task_name}_quat_relative"])

# Convert quat into eef ori mat
return dict(
target_pos=control_dict[f"{self.task_name}_pos_relative"],
target_quat=control_dict[f"{self.task_name}_quat_relative"],
target_pos=cb.as_float32(target_pos),
target_ori_mat=cb.as_float32(cb.T.quat2mat(target_quat)),
)

def _compute_no_op_action(self, control_dict):
Expand Down Expand Up @@ -370,9 +361,77 @@ def _compute_no_op_action(self, control_dict):
def _get_goal_shapes(self):
return dict(
target_pos=(3,),
target_quat=(4,),
target_ori_mat=(3, 3),
)

@property
def command_dim(self):
return IK_MODE_COMMAND_DIMS[self.mode]


import torch as th
import omnigibson.utils.transform_utils as TT
@th.jit.script
def _compute_ik_qpos_torch(
q: th.Tensor,
j_eef: th.Tensor,
ee_pos: th.Tensor,
ee_mat: th.Tensor,
goal_pos: th.Tensor,
goal_ori_mat: th.Tensor,
q_lower_limit: th.Tensor,
q_upper_limit: th.Tensor,
):
# Compute the pose error. Note that this is computed NOT in the EEF frame but still
# in the base frame.
pos_err = goal_pos - ee_pos
ori_err = TT.orientation_error(goal_ori_mat, ee_mat)
err = th.cat([pos_err, ori_err])

# Use the jacobian to compute a local approximation
j_eef_pinv = th.linalg.pinv(j_eef)
delta_j = j_eef_pinv @ err
target_joint_pos = q + delta_j

# Clip values to be within the joint limits
return target_joint_pos.clip(
min=q_lower_limit,
max=q_upper_limit,
)


import numpy as np
from numba import jit
import omnigibson.utils.transform_utils_np as NT
# Use numba since faster
@jit(nopython=True)
def _compute_ik_qpos_numpy(
q,
j_eef,
ee_pos,
ee_mat,
goal_pos,
goal_ori_mat,
q_lower_limit,
q_upper_limit,
):
# Compute the pose error. Note that this is computed NOT in the EEF frame but still
# in the base frame.
pos_err = goal_pos - ee_pos
ori_err = NT.orientation_error(goal_ori_mat, ee_mat).astype(np.float32)
err = np.concatenate((pos_err, ori_err))

# Use the jacobian to compute a local approximation
j_eef_pinv = np.linalg.pinv(j_eef)
delta_j = j_eef_pinv @ err
target_joint_pos = q + delta_j

# Clip values to be within the joint limits
return target_joint_pos.clip(q_lower_limit, q_upper_limit)


# Set these as part of the backend values
setattr(_ControllerBackend, "compute_ik_qpos", None)
setattr(_ControllerTorchBackend, "compute_ik_qpos", _compute_ik_qpos_torch)
setattr(_ControllerNumpyBackend, "compute_ik_qpos", _compute_ik_qpos_numpy)

59 changes: 56 additions & 3 deletions omnigibson/controllers/joint_controller.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import math

from omnigibson.controllers.controller_base import _ControllerBackend, _ControllerTorchBackend, _ControllerNumpyBackend
from omnigibson.controllers.controller_base import _controller_backend as cb
from omnigibson.controllers import (
ControlType,
Expand Down Expand Up @@ -210,9 +211,7 @@ def compute_control(self, goal_dict, control_dict):
else: # effort
u = target

dof_idxs_mat = cb.meshgrid(self.dof_idx, self.dof_idx)
mm = control_dict["mass_matrix"][dof_idxs_mat]
u = mm @ u
u = cb.compute_joint_torques(u, control_dict["mass_matrix"], self.dof_idx)

# Add gravity compensation
if self._use_gravity_compensation:
Expand Down Expand Up @@ -284,3 +283,57 @@ def control_type(self):
@property
def command_dim(self):
return len(self.dof_idx)


import torch as th
@th.compile
def _compute_joint_torques_torch(
u: th.Tensor,
mm: th.Tensor,
dof_idx: th.Tensor,
):
dof_idxs_mat = th.meshgrid(dof_idx, dof_idx, indexing="xy")
return mm[dof_idxs_mat] @ u



import numpy as np
from numba import jit
# Use numba since faster
@jit(nopython=True)
def numba_ix(arr, rows, cols):
"""
Numba compatible implementation of arr[np.ix_(rows, cols)] for 2D arrays.

Implementation from:
https://github.com/numba/numba/issues/5894#issuecomment-974701551

:param arr: 2D array to be indexed
:param rows: Row indices
:param cols: Column indices
:return: 2D array with the given rows and columns of the input array
"""
one_d_index = np.zeros(len(rows) * len(cols), dtype=np.int32)
for i, r in enumerate(rows):
start = i * len(cols)
one_d_index[start: start + len(cols)] = cols + arr.shape[1] * r

arr_1d = arr.reshape((arr.shape[0] * arr.shape[1], 1))
slice_1d = np.take(arr_1d, one_d_index)
return slice_1d.reshape((len(rows), len(cols)))


@jit(nopython=True)
def _compute_joint_torques_numpy(
u,
mm,
dof_idx,
):
return numba_ix(mm, dof_idx, dof_idx) @ u


# Set these as part of the backend values
setattr(_ControllerBackend, "compute_joint_torques", None)
setattr(_ControllerTorchBackend, "compute_joint_torques", _compute_joint_torques_torch)
setattr(_ControllerNumpyBackend, "compute_joint_torques", _compute_joint_torques_numpy)

2 changes: 1 addition & 1 deletion omnigibson/controllers/osc_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def compute_control(self, goal_dict, control_dict):
goal_dict (Dict[str, Any]): dictionary that should include any relevant keyword-mapped
goals necessary for controller computation. Must include the following keys:
target_pos: robot-frame (x,y,z) desired end effector position
target_quat: robot-frame (x,y,z,w) desired end effector quaternion orientation
target_ori_mat: robot-frame desired end effector quaternion orientation matrix
control_dict (Dict[str, Any]): dictionary that should include any relevant keyword-mapped
states necessary for controller computation. Must include the following keys:
joint_position: Array of current joint positions
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/objects/object_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _initialize(self):
"emissive_intensity": material.emissive_intensity,
}

@property
@cached_property
def articulation_root_path(self):
has_articulated_joints, has_fixed_joints = self.n_joints > 0, self.n_fixed_joints > 0
if self.kinematic_only or ((not has_articulated_joints) and (not has_fixed_joints)):
Expand Down
3 changes: 2 additions & 1 deletion omnigibson/prims/cloth_prim.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import math
from collections.abc import Iterable
from functools import cached_property

import torch as th

Expand Down Expand Up @@ -160,7 +161,7 @@ def n_particles(self):
"""
return self._n_particles

@property
@cached_property
def kinematic_only(self):
"""
Returns:
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/prims/entity_prim.py
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ def self_collisions(self, flag):
self.articulation_root_path, "physxArticulation:enabledSelfCollisions", flag
)

@property
@cached_property
def kinematic_only(self):
"""
Returns:
Expand Down
16 changes: 12 additions & 4 deletions omnigibson/prims/joint_prim.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def __init__(
self._joint_type = None
self._control_type = None
self._driven = None
self._body0 = None
self._body1 = None

# The following values will only be valid if this joint is part of an articulation
self._n_dof = None # The number of degrees of freedom this joint provides
Expand Down Expand Up @@ -232,8 +234,10 @@ def body0(self):
None or str: Absolute prim path to the body prim to set as this joint's parent link, or None if there is
no body0 specified.
"""
targets = self._prim.GetRelationship("physics:body0").GetTargets()
return targets[0].__str__() if len(targets) > 0 else None
if self._body0 is None:
targets = self._prim.GetRelationship("physics:body0").GetTargets()
self._body0 = targets[0].__str__()
return self._body0

@body0.setter
def body0(self, body0):
Expand All @@ -246,6 +250,7 @@ def body0(self, body0):
# Make sure prim path is valid
assert lazy.omni.isaac.core.utils.prims.is_prim_path_valid(body0), f"Invalid body0 path specified: {body0}"
self._prim.GetRelationship("physics:body0").SetTargets([lazy.pxr.Sdf.Path(body0)])
self._body0 = None

@property
def body1(self):
Expand All @@ -256,8 +261,10 @@ def body1(self):
None or str: Absolute prim path to the body prim to set as this joint's child link, or None if there is
no body1 specified.
"""
targets = self._prim.GetRelationship("physics:body1").GetTargets()
return targets[0].__str__()
if self._body1 is None:
targets = self._prim.GetRelationship("physics:body1").GetTargets()
self._body1 = targets[0].__str__()
return self._body1

@body1.setter
def body1(self, body1):
Expand All @@ -270,6 +277,7 @@ def body1(self, body1):
# Make sure prim path is valid
assert lazy.omni.isaac.core.utils.prims.is_prim_path_valid(body1), f"Invalid body1 path specified: {body1}"
self._prim.GetRelationship("physics:body1").SetTargets([lazy.pxr.Sdf.Path(body1)])
self._body1 = None

@property
def local_orientation(self):
Expand Down
11 changes: 6 additions & 5 deletions omnigibson/robots/a1.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from functools import cached_property

import torch as th

Expand Down Expand Up @@ -167,23 +168,23 @@ def _default_joint_pos(self):
def finger_lengths(self):
return {self.default_arm: 0.087}

@property
@cached_property
def arm_link_names(self):
return {self.default_arm: [f"arm_seg{i+1}" for i in range(5)]}

@property
@cached_property
def arm_joint_names(self):
return {self.default_arm: [f"arm_joint{i+1}" for i in range(6)]}

@property
@cached_property
def eef_link_names(self):
return {self.default_arm: self._eef_link_names}

@property
@cached_property
def finger_link_names(self):
return {self.default_arm: self._finger_link_names}

@property
@cached_property
def finger_joint_names(self):
return {self.default_arm: self._finger_joint_names}

Expand Down
2 changes: 1 addition & 1 deletion omnigibson/robots/active_camera_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def _default_controller_config(self):

return cfg

@property
@cached_property
@abstractmethod
def camera_joint_names(self):
"""
Expand Down
Loading