robocup_knowledge
rpo2023/challenge_restaurant.py
Go to the documentation of this file.
1 # TU/e Robotics
2 from robocup_knowledge import knowledge_loader
3 
4 # Common knowledge
5 common = knowledge_loader.load_knowledge("common")
6 
7 order_grammar = """
8 O[P] -> ORDER[P]
9 ORDER[OO] -> ITEM1[OO] | ITEM2[OO] | ITEM3[OO]
10 ITEM1[{"item1": F1}] -> ITEM[F1]
11 ITEM2[{"item1": F1, "item2": F2}] -> ITEM[F1] and ITEM[F2]
12 ITEM3[{"item1": F1, "item2": F2, "item3": F3}] -> ITEM[F1] ITEM[F2] and ITEM[F3]
13 """
14 
15 # Create grammar
16 for d in common.objects:
17  if d["category"] in ["drink", "fruit", "snack", "pantry_item"]:
18  name = d["name"]
19  order_grammar += f"\nITEM['{name}'] -> {name}"
20 
21 
22 if __name__ == "__main__":
23  import rospy
24  from robot_skills.api import Api
25 
26  rospy.init_node('blaat')
27  a = Api("hero", None)
28  rospy.sleep(rospy.Duration(0.5))
29  while not rospy.is_shutdown():
30  try:
31  result = a.query("blaat", order_grammar, "O")
32  except Exception:
33  pass
34  rospy.Duration(3.0)