Skip to content

Commit ba1d231

Browse files
committed
(hopefully) all ready.
1 parent d61b20d commit ba1d231

File tree

8 files changed

+51
-12
lines changed

8 files changed

+51
-12
lines changed
Loading
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<launch>
22
<arg name="config" default="full"/>
33
<arg name="tablet" default="true"/>
4-
<arg name="tablet_on_head" default="true"/>
54
<rosparam command="load" file="$(find coffee_shop)/config/$(arg config).yaml" />
6-
<node pkg="coffee_shop" type="main.py" name="main" output="screen" args="$(find coffee_shop)/config/$(arg config).yaml $(arg tablet) $(arg tablet_on_head)"/>
5+
<node pkg="coffee_shop" type="main.py" name="main" output="screen" args="$(find coffee_shop)/config/$(arg config).yaml $(arg tablet)"/>
76
</launch>

tasks/coffee_shop/nodes/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
if __name__ == "__main__":
88
rospy.init_node("coffee_shop")
99

10-
if len(sys.argv) < 4:
10+
if len(sys.argv) < 3:
1111
rospy.signal_shutdown("No configuration was provided")
1212
sys.exit()
13-
context = Context(sys.argv[1], sys.argv[2], sys.argv[3])
13+
context = Context(sys.argv[1], sys.argv[2])
1414

1515
coffee_shop = CoffeeShop(context)
1616
outcome = coffee_shop.execute()

tasks/coffee_shop/scripts/test_make_order.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
context = Context(sys.argv[1], sys.argv[2])
1818
context.current_table = "table0"
1919
context.tables[context.current_table]["status"] = "currently serving"
20-
context.tables[context.current_table]["order"] = ["cup", "cup"]
20+
context.tables[context.current_table]["order"] = ["banana"]
2121

2222
with sm:
2323
sm.add(

tasks/coffee_shop/src/coffee_shop/context.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818

1919
class Context:
20-
def __init__(self, config_path=None, tablet=False, tablet_on_head=False):
20+
def __init__(self, config_path=None, tablet=False):
2121
self.tablet = tablet
22-
self.tablet_on_head = tablet_on_head
23-
22+
self.tablet_on_head = False
23+
rospy.loginfo(f"Tablet: {self.tablet}, Tablet on head: {self.tablet_on_head}")
2424
self.move_base_client = actionlib.SimpleActionClient(
2525
"/move_base", MoveBaseAction
2626
)

tasks/coffee_shop/src/coffee_shop/phases/phase_2/states/check_order.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
import cv2_img
88
from play_motion_msgs.msg import PlayMotionGoal
99
from collections import Counter
10-
from geometry_msgs.msg import Point
10+
from geometry_msgs.msg import Point, Pose, Quaternion
1111
from shapely.geometry import Point as ShapelyPoint, Polygon
12+
from move_base_msgs.msg import MoveBaseGoal
1213

1314

1415
class CheckOrder(smach.State):
@@ -41,6 +42,15 @@ def execute(self, userdata):
4142

4243
self.n_checks += 1
4344

45+
position = rospy.get_param("counter/location/position")
46+
orientation = rospy.get_param("counter/location/orientation")
47+
move_base_goal = MoveBaseGoal()
48+
move_base_goal.target_pose.header.frame_id = "map"
49+
move_base_goal.target_pose.pose = Pose(
50+
position=Point(**position), orientation=Quaternion(**orientation)
51+
)
52+
self.context.move_base_client.send_goal_and_wait(move_base_goal)
53+
4454
pm_goal = PlayMotionGoal(motion_name="check_table_low", skip_planning=True)
4555
self.context.play_motion_client.send_goal_and_wait(pm_goal)
4656

tasks/coffee_shop/src/coffee_shop/phases/phase_2/states/take_order.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ def execute(self, userdata):
9696
if self.context.tablet_on_head:
9797
pm_goal = PlayMotionGoal(motion_name="tablet", skip_planning=True)
9898
self.context.play_motion_client.send_goal_and_wait(pm_goal)
99+
rospy.loginfo("Tablet is on the head")
99100
else:
100-
101+
rospy.loginfo("Tablet is not on the head")
101102
robot_pose = rospy.wait_for_message(
102103
"/amcl_pose", PoseWithCovarianceStamped
103104
).pose.pose

tasks/coffee_shop/src/coffee_shop/phases/phase_2/states/wait_for_order.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
from play_motion_msgs.msg import PlayMotionGoal
55
import difflib
66
from std_msgs.msg import Empty, String
7+
import numpy as np
8+
from geometry_msgs.msg import Pose, Point, Quaternion, PoseWithCovarianceStamped
9+
from move_base_msgs.msg import MoveBaseGoal
10+
from scipy.spatial.transform import Rotation as R
711

812

913
class WaitForOrder(smach.State):
@@ -37,8 +41,33 @@ def execute(self, userdata):
3741
self.context.voice_controller.sync_tts(
3842
"Please press 'done' when you are ready for me to check the order."
3943
)
40-
pm_goal = PlayMotionGoal(motion_name="tablet", skip_planning=True)
41-
self.context.play_motion_client.send_goal_and_wait(pm_goal)
44+
if self.context.tablet_on_head:
45+
pm_goal = PlayMotionGoal(motion_name="tablet", skip_planning=True)
46+
self.context.play_motion_client.send_goal_and_wait(pm_goal)
47+
else:
48+
robot_pose = rospy.wait_for_message(
49+
"/amcl_pose", PoseWithCovarianceStamped
50+
).pose.pose
51+
target_orientation = R.from_quat(
52+
[
53+
robot_pose.orientation.x,
54+
robot_pose.orientation.y,
55+
robot_pose.orientation.z,
56+
robot_pose.orientation.w,
57+
]
58+
) * R.from_euler("z", np.pi, degrees=False)
59+
move_base_goal = MoveBaseGoal()
60+
move_base_goal.target_pose.header.frame_id = "map"
61+
move_base_goal.target_pose.pose = Pose(
62+
position=robot_pose.position,
63+
orientation=Quaternion(*target_orientation.as_quat()),
64+
)
65+
self.context.move_base_client.send_goal_and_wait(move_base_goal)
66+
pm_goal = PlayMotionGoal(
67+
motion_name="tablet_no_head", skip_planning=True
68+
)
69+
self.context.play_motion_client.send_goal_and_wait(pm_goal)
70+
4271
self.tablet_pub.publish(String("done"))
4372
rospy.wait_for_message("/tablet/done", Empty)
4473
return "done"

0 commit comments

Comments
 (0)