Skip to content

Commit f45d2fd

Browse files
committed
Tune coffee skills: fix button press, gradual fill, table collision, pour
- Fix button press to use Euclidean distance instead of squared distance - Increase button press threshold for pybullet coffee - Stop re-creating liquid in gradual fill once jug is full - Add table to collision bodies in motion planning - Skip MoveAbovePour phase in pour skill - Reduce liquid body mass [coffee-new-skills]
1 parent fefe90d commit f45d2fd

4 files changed

Lines changed: 23 additions & 12 deletions

File tree

predicators/envs/coffee.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,8 +795,8 @@ def _PressingButton_holds(self, state: State,
795795
x = state.get(robot, "x")
796796
y = state.get(robot, "y")
797797
z = state.get(robot, "z")
798-
sq_dist_to_button = np.sum(np.subtract(button_pos, (x, y, z))**2)
799-
return sq_dist_to_button < self.button_press_threshold
798+
dist_to_button = np.sqrt(np.sum(np.subtract(button_pos, (x, y, z))**2))
799+
return dist_to_button < self.button_press_threshold
800800

801801
@staticmethod
802802
def _NotSameCup_holds(state: State, objects: Sequence[Object]) -> bool:

predicators/envs/pybullet_coffee.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class PyBulletCoffeeEnv(PyBulletEnv, CoffeeEnv):
113113
button_y: ClassVar[float] =\
114114
machine_y - machine_y_len / 2 - machine_top_y_len - button_height/2
115115
button_z: ClassVar[float] = z_lb + machine_z_len - button_radius
116-
button_press_threshold: ClassVar[float] = 1e-2
116+
button_press_threshold: ClassVar[float] = 3e-2
117117
machine_color: ClassVar[Tuple[float, float, float, float]] =\
118118
(0.1, 0.1, 0.1, 1) # Black
119119
button_color_on: ClassVar[Tuple[float, float, float,
@@ -575,6 +575,18 @@ def _handle_machine_on_and_jug_filling(self, state: State) -> None:
575575
or self._machine_plugged_in_id is not None)):
576576
if CFG.coffee_fill_jug_gradually:
577577
# Gradual filling
578+
if self._jug_current_liquid < self.max_jug_coffee_capacity:
579+
self._jug_current_liquid = min(
580+
self.max_jug_coffee_capacity,
581+
self._jug_current_liquid +
582+
self.coffee_machine_fill_speed)
583+
self._jug_liquid_id = self._create_liquid_for_jug()
584+
if (not self._jug_filled and
585+
self._jug_current_liquid >
586+
self.coffee_filled_threshold):
587+
self._jug_filled = True
588+
else:
589+
# Instant filling
578590
self._jug_current_liquid = min(
579591
self.max_jug_coffee_capacity,
580592
self._jug_current_liquid +
@@ -583,11 +595,6 @@ def _handle_machine_on_and_jug_filling(self, state: State) -> None:
583595
if (not self._jug_filled and self._jug_current_liquid >
584596
self.coffee_filled_threshold):
585597
self._jug_filled = True
586-
else:
587-
# Instant filling
588-
if not self._jug_filled:
589-
self._jug_liquid_id = self._create_liquid_for_jug()
590-
self._jug_filled = True
591598

592599
def _handle_pouring(self, state: State) -> None:
593600
"""If the robot is tilted sufficiently to pour, increase liquid in the
@@ -781,7 +788,7 @@ def _create_liquid_for_jug(self) -> int:
781788
liquid_pos = (jug_pos[0], jug_pos[1],
782789
self.z_lb + liquid_height / 2 + 0.02)
783790

784-
return p.createMultiBody(baseMass=0.001,
791+
return p.createMultiBody(baseMass=1e-5,
785792
baseCollisionShapeIndex=collision_id,
786793
baseVisualShapeIndex=visual_id,
787794
basePosition=liquid_pos,

predicators/ground_truth_models/skill_factories/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,11 @@ def _plan_with_simulator(
544544
continue
545545
collision_bodies.add(sim_obj.id)
546546

547-
# 4b. Add extra sim collision bodies (e.g. virtual buffer zones).
547+
# 4b. Add the table if present.
548+
if hasattr(sim, '_table') and sim._table.id is not None:
549+
collision_bodies.add(sim._table.id)
550+
551+
# 4c. Add extra sim collision bodies (e.g. virtual buffer zones).
548552
collision_bodies.update(self._config.sim_extra_collision_bodies)
549553

550554
# 5. IK + motion planning on simulator's robot

predicators/ground_truth_models/skill_factories/pour.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ def _tilt_target(
124124
return current_pose, target_pose, "closed"
125125

126126
phases = [
127-
# Phase 0: Move above pour position at normal tilt
128-
make_move_to_phase("MoveAbovePour", _above_pose, "closed"),
127+
# # Phase 0: Move above pour position at normal tilt
128+
# make_move_to_phase("MoveAbovePour", _above_pose, "closed"),
129129
# Phase 1: Descend to pour height at normal tilt
130130
make_move_to_phase("DescendToPour", _descend_pose, "closed"),
131131
# Phase 2: Tilt EE to pour angle (incremental IK for fine control)

0 commit comments

Comments
 (0)