Skip to content

Commit 9857995

Browse files
committed
Store table IDs as _table_ids in PyBullet envs for motion planning
Add self._table_ids attribute in _store_pybullet_bodies for boil, grow, coffee, fan, and domino environments. For boil and domino, also capture the second table's ID in initialize_pybullet.
1 parent 5f0d402 commit 9857995

5 files changed

Lines changed: 28 additions & 18 deletions

File tree

predicators/envs/pybullet_boil.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,16 @@ def initialize_pybullet(
358358
)
359359
bodies["table_id"] = table_id
360360
# add another table for more space to place jugs and burners
361-
create_object(asset_path="urdf/table.urdf",
362-
position=(cls.table_pos[0],
363-
cls.table_pos[1] + (cls.y_ub - cls.y_lb) / 2,
364-
cls.table_pos[2]),
365-
orientation=cls.table_orn,
366-
scale=1.0,
367-
use_fixed_base=True,
368-
physics_client_id=physics_client_id)
361+
table_id2 = create_object(
362+
asset_path="urdf/table.urdf",
363+
position=(cls.table_pos[0],
364+
cls.table_pos[1] + (cls.y_ub - cls.y_lb) / 2,
365+
cls.table_pos[2]),
366+
orientation=cls.table_orn,
367+
scale=1.0,
368+
use_fixed_base=True,
369+
physics_client_id=physics_client_id)
370+
bodies["table_id2"] = table_id2
369371

370372
# 2) Create jugs
371373
jug_ids = []
@@ -436,6 +438,8 @@ def initialize_pybullet(
436438

437439
def _store_pybullet_bodies(self, pybullet_bodies: Dict[str, Any]) -> None:
438440
"""Store references to all PyBullet IDs in the environment objects."""
441+
self._table_ids = [pybullet_bodies["table_id"],
442+
pybullet_bodies["table_id2"]]
439443
self._robot.id = self._pybullet_robot.robot_id
440444
# Jugs
441445
for i, jug_obj in enumerate(self._jugs):

predicators/envs/pybullet_coffee.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ def initialize_pybullet(
302302
return physics_client_id, pybullet_robot, bodies
303303

304304
def _store_pybullet_bodies(self, pybullet_bodies: Dict[str, Any]) -> None:
305+
self._table_ids = [pybullet_bodies["table_id"]]
305306
self._table.id = pybullet_bodies["table_id"]
306307
self._jug.id = pybullet_bodies["jug_id"]
307308
self._machine.id = pybullet_bodies["machine_id"]

predicators/envs/pybullet_domino/composed_env.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -238,20 +238,23 @@ def initialize_pybullet(
238238
physics_client_id=physics_client_id)
239239

240240
# Add second table for more space
241-
create_object(asset_path="urdf/table.urdf",
242-
position=(cls.table_pos[0],
243-
cls.table_pos[1] + cls.table_width / 2,
244-
cls.table_pos[2]),
245-
orientation=cls.table_orn,
246-
scale=1.0,
247-
use_fixed_base=True,
248-
physics_client_id=physics_client_id)
249-
250-
bodies = {"table_id": table_id}
241+
table_id2 = create_object(
242+
asset_path="urdf/table.urdf",
243+
position=(cls.table_pos[0],
244+
cls.table_pos[1] + cls.table_width / 2,
245+
cls.table_pos[2]),
246+
orientation=cls.table_orn,
247+
scale=1.0,
248+
use_fixed_base=True,
249+
physics_client_id=physics_client_id)
250+
251+
bodies = {"table_id": table_id, "table_id2": table_id2}
251252
return physics_client_id, pybullet_robot, bodies
252253

253254
def _store_pybullet_bodies(self, pybullet_bodies: Dict[str, Any]) -> None:
254255
"""Initialize and store PyBullet bodies for all components."""
256+
self._table_ids = [pybullet_bodies["table_id"],
257+
pybullet_bodies["table_id2"]]
255258
# Initialize each component
256259
for comp in self._components:
257260
comp.set_physics_client_id(self._physics_client_id)

predicators/envs/pybullet_fan.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ def _get_joint_id(obj_id: int,
563563

564564
def _store_pybullet_bodies(self, pybullet_bodies: Dict[str, Any]) -> None:
565565
"""Store references to all PyBullet object IDs and their joints."""
566+
self._table_ids = [pybullet_bodies["table_id"]]
566567
# 0 = left, 1 = right, 2 = back, 3 = front
567568

568569
# Store all fan IDs grouped by side

predicators/envs/pybullet_grow.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ def initialize_pybullet(
235235
def _store_pybullet_bodies(self, pybullet_bodies: Dict[str, Any]) -> None:
236236
"""Store references (IDs) to cups and jugs inside self._cups,
237237
self._jugs."""
238+
self._table_ids = [pybullet_bodies["table_id"]]
238239
for i, cup in enumerate(self._cups):
239240
cup.id = pybullet_bodies["cup_ids"][i]
240241
for i, jug in enumerate(self._jugs):

0 commit comments

Comments
 (0)