Skip to content

Commit

Permalink
Merge pull request SUTURO#53 from Julislz/MS2
Browse files Browse the repository at this point in the history
 [Receptionist] code for testing new perception features
  • Loading branch information
Julislz authored Mar 28, 2024
2 parents c9c2510 + f0c44ce commit c332948
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
1 change: 0 additions & 1 deletion demos/pycram_receptionist_demo/tests/MS3_testable.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def demo_tst():

# introduce humans and look at them
giskardpy.move_head_to_human()
print("täsr" + misc.host.fav_drink)
misc.introduce(pose_b=pose_host, pose_a=pose_guest)


Expand Down
19 changes: 19 additions & 0 deletions demos/pycram_receptionist_demo/tests/perception_humans.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
def p():
with real_robot:

# to signal the start of demo
TalkingMotion("Hello, i am ready for the test").resolve().perform()

# does the code work with the manipulation feature?
giskardpy.move_head_to_human()

# old Detection Query
DetectAction(technique='human', state='start').resolve().perform()

rospy.loginfo("human detected")
Expand All @@ -48,6 +55,18 @@ def p():

print("------------------------------- stop")

# new Query to detect attributes of a human
TalkingMotion("detecting attributes now").resolve().perform()
attributes = DetectAction(technique='attributes').resolve().perform()
rospy.loginfo("Attributes: " + str(attributes))
rospy.sleep(5)

# new Query for free seat
#TalkingMotion("detecting free seat now").resolve().perform()
#seat = DetectAction(technique='location', state='seat1').resolve().perform()
#rospy.loginfo("seat bool: " + str(attributes))
#rospy.sleep(5)

print("end")


Expand Down
15 changes: 7 additions & 8 deletions src/pycram/external_interfaces/robokudo.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def callback(pose):
human_bool = True
human_pose = pose


# create client to communicate with perception
client = actionlib.SimpleActionClient('robokudo/query', QueryAction)
rospy.loginfo("Waiting for action server")
client.wait_for_server()
Expand Down Expand Up @@ -218,9 +218,10 @@ def stop_queryHuman() -> Any:
rospy.loginfo("cancelled current goal")


def seat_queryHuman() -> Any:
def seat_queryHuman(seat: str) -> Any:
"""
Sends a query to RoboKudo to look for a free place to sit and look for a human
Sends a query to RoboKudo to check if a place is free to sit
:param seat: name of the seat/region, that will be checked
"""
init_robokudo_interface()
from robokudo_msgs.msg import QueryAction, QueryGoal, QueryResult
Expand All @@ -235,15 +236,14 @@ def done_callback(state, result: QueryResult):
global query_result
query_result = result.res


# fill Query with information so that perception looks for a seat
object_goal = QueryGoal()
object_goal.obj.location = "seat" # aktivate region filter
object_goal.obj.attribute = ["attributes"] # gender, bright/dark top, x, hat or no hat
object_goal.obj.location = seat # aktivate region filter

client = actionlib.SimpleActionClient('robokudo/query', QueryAction)
rospy.loginfo("Waiting for action server")
client.wait_for_server()
rospy.loginfo("Query to Perception: " + str(object_goal))
client.send_goal(object_goal, active_cb=active_callback, done_cb=done_callback)
# TODO: necessary?
client.wait_for_result()
Expand All @@ -268,15 +268,14 @@ def done_callback(state, result: QueryResult):
global query_result
query_result = result



object_goal = QueryGoal()
# Perception will detect gender, clothes, skin color, age
object_goal.obj.attribute = ["attributes"]

client = actionlib.SimpleActionClient('robokudo/query', QueryAction)
rospy.loginfo("Waiting for action server")
client.wait_for_server()
rospy.loginfo("Query to Perception: " + str(object_goal))
client.send_goal(object_goal, active_cb=active_callback, done_cb=done_callback)
# TODO: necessary?
client.wait_for_result()
Expand Down
7 changes: 4 additions & 3 deletions src/pycram/process_modules/hsrb_process_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,12 @@ def _execute(self, desig: DetectingMotion.Motion) -> Any:
return "stopped"
elif desig.technique == 'location':
# TODO: test what and how Perception returns Query msg and make it fit rest of code
seat_human_pose = seat_queryHuman()
seat = desig.state
seat_human_pose = seat_queryHuman(seat)
return seat_human_pose
elif desig.technique == 'attributes':
seat_human_pose = attributes_queryHuman()
return seat_human_pose
human_pose_attr = attributes_queryHuman()
return human_pose_attr


query_result = queryEmpty(ObjectDesignatorDescription(types=[desig.object_type]))
Expand Down

0 comments on commit c332948

Please sign in to comment.