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

Replace dynamic control APIs with Isaac.Core View APIs #336

Merged
merged 79 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
9f9c64d
Start articulationview work
cgokmen Oct 24, 2023
ea421f8
Merge branch 'og-develop' into articulationview
cgokmen Dec 6, 2023
4af5a0f
Update entityprim to use articulationview instead of dc
cgokmen Dec 6, 2023
323a4c1
Finish changes to entity prim
cgokmen Dec 6, 2023
c1dab0a
Finish removing dc stuff from rigid prim
cgokmen Dec 6, 2023
b5796ef
Some fixes to entity prim
cgokmen Dec 6, 2023
6bff1d7
Some fixes and questions on Tiago
cgokmen Dec 6, 2023
cb7e298
Update scene_base.py
cgokmen Dec 6, 2023
bb8b649
Start implementing JointPrim stuff with extended articulation view
cgokmen Dec 7, 2023
1757231
Remove simulator DC handle
cgokmen Dec 7, 2023
1d92335
Implement the remaining articulation view features
cgokmen Dec 9, 2023
e23f42c
Finish implementing articulationview stuff
cgokmen Dec 11, 2023
76f1165
Use a joint graph to filter AG candidates
cgokmen Dec 12, 2023
fb1aa64
Remove DC reference
cgokmen Dec 12, 2023
bc6f761
Merge branch 'og-develop' into articulationview
cgokmen Dec 12, 2023
0a25495
Match set_local_pose signature to other position/orientation by renam…
cgokmen Dec 12, 2023
85c364b
Address comments
cgokmen Dec 12, 2023
0e93f07
Reorder view creation
cgokmen Dec 12, 2023
8265936
Remove references to mass API
cgokmen Dec 12, 2023
757b144
Some fixes
cgokmen Dec 13, 2023
2c81195
Remove trivial assert function
cgokmen Dec 13, 2023
7348f8d
Fix targets
cgokmen Dec 13, 2023
dac0927
Remove articulation tree, which does not work because fixed links are…
cgokmen Dec 13, 2023
00ce7c5
Fix bug in joint finding
cgokmen Dec 13, 2023
4b6ecc1
Temporarily disable tree-based AG type selection
cgokmen Dec 13, 2023
3462fcc
Fix has_limits
cgokmen Dec 13, 2023
6e31953
Better compute of eef link idx
cgokmen Dec 13, 2023
66a46a8
Remove references to physics view
cgokmen Dec 13, 2023
b922a5f
Some fixes
cgokmen Dec 13, 2023
fe44403
Fix some naiveties
cgokmen Dec 13, 2023
bd54838
Some fixes
cgokmen Dec 13, 2023
d774505
Make nonarticulated entityprims defer to xformprim for position setti…
cgokmen Dec 13, 2023
dd49f35
Reorder some things
cgokmen Dec 13, 2023
8b8eef5
Implement proper is_articulated checks for entity and joint
cgokmen Dec 13, 2023
e5dd359
Back to root path
cgokmen Dec 13, 2023
9e43641
Don't read info about fixed joints
cgokmen Dec 13, 2023
6b0a3f1
Disable a bunch of APIs for kinematic-only bodies.
cgokmen Dec 14, 2023
b610f6d
Create the views during initialization time so that we can use all in…
cgokmen Dec 14, 2023
4d85830
Allow the use of XFormPrim methods until the rigid body is initialized.
cgokmen Dec 14, 2023
fb752fb
Revert "Allow the use of XFormPrim methods until the rigid body is in…
cgokmen Dec 14, 2023
2a078d8
Revert "Create the views during initialization time so that we can us…
cgokmen Dec 14, 2023
ff36fdb
Make n_joints not depend on _links
cgokmen Dec 14, 2023
d785ccd
Move the kinematic_only decision mechanism
cgokmen Dec 14, 2023
e5748b4
Remove unavailable API call
cgokmen Dec 14, 2023
91f6da5
Fix typos
cgokmen Dec 14, 2023
d403e6d
Don't touch gravity on kinematic-only objects
cgokmen Dec 14, 2023
5c2fe60
Don't set mass/density for kinematic-only objects
cgokmen Dec 14, 2023
ffd84bc
Do not initialize rigid prim view for kinematic-only objects.
cgokmen Dec 14, 2023
19b7689
Some fixes
cgokmen Dec 15, 2023
371496f
Some fixes
cgokmen Dec 15, 2023
45010bc
Use custom rigid prim class
cgokmen Dec 15, 2023
e9eda29
Bunch of fixes
cgokmen Dec 16, 2023
8934baa
More verbose error
cgokmen Dec 16, 2023
25beea7
Unbreak cloth
cgokmen Dec 16, 2023
5bd5674
Don't forget to clear the xform API
cgokmen Dec 19, 2023
ae0f5ec
Delegate to RigidPrim instead of XFormPrim if a root link exists
cgokmen Dec 19, 2023
dafe3f7
Update entity_prim.py
cgokmen Dec 19, 2023
9dea922
Make RigidPrim reset BoundingBoxAPI too
cgokmen Dec 19, 2023
5eacdce
Make particles fixed base
cgokmen Dec 19, 2023
de1ee67
Don't set kinematic only manually for particles, this is now auto-com…
cgokmen Dec 19, 2023
86373ee
Some fixes to manipulation robot
cgokmen Dec 19, 2023
f1ace51
better update handles logic
cgokmen Dec 19, 2023
53c62a6
Quick fix
cgokmen Dec 19, 2023
68a6db8
Make the contact API use the sensor paths from the view
cgokmen Dec 19, 2023
1d8a2ec
Some fixes
cgokmen Dec 19, 2023
bca5b73
Some fixes
cgokmen Dec 19, 2023
a298dc3
Check if sim is playing
cgokmen Dec 19, 2023
8158f55
Apply the valid view requirement only for initialized objects
cgokmen Dec 19, 2023
87ebe88
Revert "Remove articulation tree, which does not work because fixed l…
cgokmen Dec 20, 2023
c98979a
Reimplement articulation graph
cgokmen Dec 20, 2023
73fdb83
Fix articulation tree
cgokmen Dec 20, 2023
10804c1
Small fix
cgokmen Dec 20, 2023
588ffab
Fix joint type
cgokmen Dec 20, 2023
263fa51
Fix RigidContactAPI
cgokmen Dec 20, 2023
508db28
Undo changes to RigidContactAPI
cgokmen Dec 20, 2023
f945361
Fix AG mechanism
cgokmen Dec 20, 2023
2174058
Small bugfix
cgokmen Dec 20, 2023
7958f5c
Address comments
cgokmen Dec 21, 2023
8d58b6c
Merge branch 'og-develop' into articulationview
cgokmen Dec 21, 2023
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
2 changes: 1 addition & 1 deletion omnigibson/object_states/particle_modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def overlap_callback(hit):
z_offset = 0.0 if self._projection_mesh_params["type"] == "Sphere" else self._projection_mesh_params["extents"][2] / 2

self.projection_mesh.set_local_pose(
translation=np.array([0, 0, -z_offset]),
position=np.array([0, 0, -z_offset]),
orientation=T.euler2quat([0, 0, 0]),
)

Expand Down
2 changes: 1 addition & 1 deletion omnigibson/object_states/toggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def _initialize(self):
self.visual_marker.visible = True

# Make sure the marker isn't translated at all
self.visual_marker.set_local_pose(translation=np.zeros(3), orientation=np.array([0, 0, 0, 1.0]))
self.visual_marker.set_local_pose(position=np.zeros(3), orientation=np.array([0, 0, 0, 1.0]))

# Store the projection mesh's IDs
projection_mesh_ids = PhysicsSchemaTools.encodeSdfPath(self.visual_marker.prim_path)
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 @@ -242,7 +242,7 @@ def reload_controllers(self, controller_config=None):
else self._create_continuous_action_space()

def reset(self):
# Make sure simulation is playing, otherwise, we cannot reset because DC requires active running
# Make sure simulation is playing, otherwise, we cannot reset because physx requires active running
# simulation in order to set joints
assert og.sim.is_playing(), "Simulator must be playing in order to reset controllable object's joints!"

Expand Down
358 changes: 82 additions & 276 deletions omnigibson/prims/entity_prim.py

Large diffs are not rendered by default.

178 changes: 64 additions & 114 deletions omnigibson/prims/joint_prim.py

Large diffs are not rendered by default.

203 changes: 47 additions & 156 deletions omnigibson/prims/rigid_prim.py

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions omnigibson/prims/xform_prim.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def set_position_orientation(self, position=None, orientation=None):
calculated_translation = transform.GetTranslation()
calculated_orientation = transform.GetRotation().GetQuat()
self.set_local_pose(
translation=np.array(calculated_translation), orientation=gf_quat_to_np_array(calculated_orientation)[[1, 2, 3, 0]] # Flip from w,x,y,z to x,y,z,w
position=np.array(calculated_translation), orientation=gf_quat_to_np_array(calculated_orientation)[[1, 2, 3, 0]] # Flip from w,x,y,z to x,y,z,w
)

def get_position_orientation(self):
Expand Down Expand Up @@ -268,24 +268,24 @@ def get_local_pose(self):
xform_orient_op = self.get_attribute("xformOp:orient")
return np.array(xform_translate_op), gf_quat_to_np_array(xform_orient_op)[[1, 2, 3, 0]]

def set_local_pose(self, translation=None, orientation=None):
def set_local_pose(self, position=None, orientation=None):
cgokmen marked this conversation as resolved.
Show resolved Hide resolved
"""
Sets prim's pose with respect to the local frame (the prim's parent frame).

Args:
translation (None or 3-array): if specified, (x,y,z) translation in the local frame of the prim
position (None or 3-array): if specified, (x,y,z) position in the local frame of the prim
(with respect to its parent prim). Default is None, which means left unchanged.
orientation (None or 4-array): if specified, (x,y,z,w) quaternion orientation in the local frame of the prim
(with respect to its parent prim). Default is None, which means left unchanged.
"""
properties = self.prim.GetPropertyNames()
if translation is not None:
translation = Gf.Vec3d(*np.array(translation, dtype=float))
if position is not None:
position = Gf.Vec3d(*np.array(position, dtype=float))
if "xformOp:translate" not in properties:
carb.log_error(
"Translate property needs to be set for {} before setting its position".format(self.name)
)
self.set_attribute("xformOp:translate", translation)
self.set_attribute("xformOp:translate", position)
if orientation is not None:
orientation = np.array(orientation, dtype=float)[[3, 0, 1, 2]]
if "xformOp:orient" not in properties:
Expand Down
33 changes: 13 additions & 20 deletions omnigibson/robots/manipulation_robot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from abc import abstractmethod
from collections import namedtuple
import numpy as np
import networkx as nx

import omnigibson as og
from omnigibson.macros import gm, create_module_macros
Expand Down Expand Up @@ -783,12 +784,11 @@ def _calculate_in_hand_object_rigid(self, arm="default"):

candidate_data = []
for prim_path in candidates_set:
# Calculate position of the object link
# Note: this assumes the simulator is playing!
rb_handle = self._dc.get_rigid_body(prim_path)
pose = self._dc.get_rigid_body_pose(rb_handle)
link_pos = np.asarray(pose.p)
dist = np.linalg.norm(np.array(link_pos) - np.array(gripper_center_pos))
# Calculate position of the object link. Only allow this for objects currently.
obj_prim_path, link_name = prim_path.rsplit("/", 1)[-1]
candidate_obj = og.sim.scene.object_registry("prim_path", obj_prim_path)
candidate_link = candidate_obj.links[link_name]
dist = np.linalg.norm(np.array(candidate_link.get_position()) - np.array(gripper_center_pos))
candidate_data.append((prim_path, dist))

candidate_data = sorted(candidate_data, key=lambda x: x[-1])
Expand Down Expand Up @@ -1055,21 +1055,14 @@ def _get_assisted_grasp_joint_type(self, ag_obj, ag_link):
return None

# Otherwise, compute the joint type. We use a fixed joint unless the link is a non-fixed link.
# A link is non-fixed if it has any non-fixed parent joints.
joint_type = "FixedJoint"
if ag_obj.root_link != ag_link:
# We search up the tree path from the ag_link until we encounter the root (joint == 0) or a non fixed
# joint (e.g.: revolute or fixed)
link_handle = ag_link.handle
joint_handle = self._dc.get_rigid_body_parent_joint(link_handle)
while joint_handle != 0:
# If this joint type is not fixed, we've encountered a valid moving joint
# So we create a spherical joint rather than fixed joint
if self._dc.get_joint_type(joint_handle) != JointType.JOINT_FIXED:
joint_type = "SphericalJoint"
break
# Grab the parent link and its parent joint for the link
link_handle = self._dc.get_joint_parent_body(joint_handle)
joint_handle = self._dc.get_rigid_body_parent_joint(link_handle)
articulation_graph = ag_obj.articulation_graph
for edge in nx.edge_dfs(articulation_graph, ag_link, orientation="reverse"):
joint = articulation_graph.edges[edge]["joint"]
if joint.joint_type != JointType.JOINT_FIXED:
joint_type = "SphericalJoint"
break

return joint_type

Expand Down
13 changes: 5 additions & 8 deletions omnigibson/robots/tiago.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
from pxr import Gf

import omnigibson as og
from omnigibson.macros import gm
import omnigibson.utils.transform_utils as T
from omnigibson.macros import create_module_macros
Expand Down Expand Up @@ -696,13 +697,8 @@ def arm_workspace_range(self):
}

def get_position_orientation(self):
# If the simulator is playing, return the pose of the base_footprint link frame
if self._dc is not None and self._dc.is_simulating():
return self.base_footprint_link.get_position_orientation()

# Else, return the pose of the robot frame
else:
return super().get_position_orientation()
# TODO: Investigate the need for this custom behavior.
return self.base_footprint_link.get_position_orientation()

def set_position_orientation(self, position=None, orientation=None):
current_position, current_orientation = self.get_position_orientation()
Expand All @@ -713,8 +709,9 @@ def set_position_orientation(self, position=None, orientation=None):
assert np.isclose(np.linalg.norm(orientation), 1, atol=1e-3), \
f"{self.name} desired orientation {orientation} is not a unit quaternion."

# TODO: Reconsider the need for this. Why can't these behaviors be unified? Does the joint really need to move?
cgokmen marked this conversation as resolved.
Show resolved Hide resolved
# If the simulator is playing, set the 6 base joints to achieve the desired pose of base_footprint link frame
if self._dc is not None and self._dc.is_simulating():
if og.sim.is_playing():
# Find the relative transformation from base_footprint_link ("base_footprint") frame to root_link
# ("base_footprint_x") frame. Assign it to the 6 1DoF joints that control the base.
# Note that the 6 1DoF joints are originated from the root_link ("base_footprint_x") frame.
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/scenes/scene_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def object_registry_unique_keys(self):
"""
Returns:
list of str: Keys with which to index into the object registry. These should be valid public attributes of
prims that we can use as unique IDs to reference prims, e.g., prim.prim_path, prim.name, prim.handle, etc.
prims that we can use as unique IDs to reference prims, e.g., prim.prim_path, prim.name, etc.
"""
return ["name", "prim_path", "uuid"]

Expand Down
9 changes: 0 additions & 9 deletions omnigibson/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from omni.isaac.core.simulation_context import SimulationContext
from omni.isaac.core.utils.prims import get_prim_at_path
from omni.isaac.core.utils.stage import open_stage, create_new_stage
from omni.isaac.dynamic_control import _dynamic_control
from omni.physx.bindings._physx import ContactEventType, SimulationEvent
import omni.kit.loop._loop as omni_loop
from pxr import Usd, PhysicsSchemaTools, UsdUtils
Expand Down Expand Up @@ -806,14 +805,6 @@ def __del__(self):
Simulator._world_initialized = None
return

@property
def dc(self):
cgokmen marked this conversation as resolved.
Show resolved Hide resolved
"""
Returns:
_dynamic_control.DynamicControl: Dynamic control (dc) interface
"""
return self._dynamic_control

@property
def pi(self):
"""
Expand Down
Loading
Loading