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

HITL - Add KRM to HITL. #2043

Merged
merged 2 commits into from
Aug 28, 2024
Merged
Changes from all commits
Commits
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
34 changes: 34 additions & 0 deletions examples/hitl/rearrange_v2/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,13 @@ def _pick_object(self, object_id: int) -> None:
snap_obj_id=object_id,
force=True,
)
sim = self._sim
if sim._kinematic_mode:
krm = sim.kinematic_relationship_manager
krm.relationship_graph.remove_obj_relations(
object_id, parents_only=True
)
krm.update_snapshots()

self._on_pick.invoke(
UI.PickEventData(
Expand Down Expand Up @@ -324,8 +331,21 @@ def _place_object(self) -> None:
self._place_selection.deselect()
self._world._all_held_object_ids.remove(object_id)

# Force the grasp manager to release the object.
grasp_mgr = self._get_grasp_manager()
grasp_mgr.desnap(force=True)
grasp_mgr._snapped_obj_id = None
grasp_mgr._snapped_marker_id = None
grasp_mgr._managed_articulated_agent.close_gripper()

# Update the kinematic relationships.
sim = self._sim
if sim._kinematic_mode:
krm = sim.kinematic_relationship_manager
krm.relationship_graph.add_relation(
receptacle_object_id, object_id, "ontop"
)
krm.update_snapshots()

self._on_place.invoke(
UI.PlaceEventData(
Expand Down Expand Up @@ -383,6 +403,13 @@ def _interact_with_object(self, object_id: int) -> None:
if link_id in self._world._opened_link_set:
sim_utilities.close_link(ao, link_index)
self._world._opened_link_set.remove(link_id)
if self._sim._kinematic_mode:
# first apply the current relative transform
self._sim.kinematic_relationship_manager.apply_relations()
# then update the root transform of the closed link (links are always root parents)
self._sim.kinematic_relationship_manager.update_snapshots(
root_parent_subset=[link_id]
)
self._on_close.invoke(
UI.OpenEventData(
object_id=object_id,
Expand All @@ -392,6 +419,13 @@ def _interact_with_object(self, object_id: int) -> None:
else:
sim_utilities.open_link(ao, link_index)
self._world._opened_link_set.add(link_id)
if self._sim._kinematic_mode:
# first apply the current relative transform
self._sim.kinematic_relationship_manager.apply_relations()
# then update the root transform of the opened link (links are always root parents)
self._sim.kinematic_relationship_manager.update_snapshots(
root_parent_subset=[link_id]
)
self._on_open.invoke(
UI.CloseEventData(
object_id=object_id,
Expand Down