00001 #! /usr/bin/env python 00002 00003 import roslib; roslib.load_manifest('srs_decision_making') 00004 import rospy 00005 import sys 00006 00007 import actionlib 00008 00009 import srs_decision_making.msg as xmsg 00010 00011 def DM_client(json_parameters): 00012 client = actionlib.SimpleActionClient('srs_decision_making_actions', xmsg.ExecutionAction) 00013 00014 client.wait_for_server() 00015 00016 # Creates a goal to send to the action server. 00017 _goal=xmsg.ExecutionGoal() 00018 #_goal.action="move" 00019 #_goal.parameter=target_pos 00020 #_goal.priority=0 00021 00022 _goal.json_parameters = json_parameters 00023 # Sends the goal to the action server. 00024 client.send_goal(_goal) 00025 00026 # Waits for the server to finish performing the action. 00027 client.wait_for_result() 00028 00029 # Prints out the result of executing the action 00030 return client.get_result() 00031 00032 if __name__ == '__main__': 00033 try: 00034 # Initializes a rospy node so that the SimpleActionClient can 00035 # publish and subscribe over ROS. 00036 #json_parameters = '{"tasks":[{"time_schedule":1263798000000,"task":"get","deliver_destination":{"predefined_pose":"order"},"object":{"object_type":"Milkbox"}}],"initializer":{"device_type":"ui_loc","device_id":"ui_loc_0001"}}' 00037 #json_parameters = '{"tasks":[{"time_schedule":1263798000000,"task":"get","deliver_destination":{"pose2d":{"theta":0.0,"y":0.0,"x":0.0}},"object":{"object_type":"Milkbox"}}],"initializer":{"device_type":"ui_loc","device_id":"ui_loc_0001"}}' 00038 #json_parameters = '{"tasks":[{"task":"move", "mode":"manual", "component":"torso","destination":{"predefined_pose":"front"}}],"initializer":{"device_type":"ui_pri","device_id":"ui_pri_101"}} ' 00039 #json_parameters = '{"tasks":[{"task":"move", "mode":"manual", "component":"torso","destination":{"torso_pose":{"tilt1":-0.1,"pan":0.1,"tilt2":0.15}}}],"initializer":{"device_type":"ui_pri","device_id":"ui_pri_101"}}' 00040 json_parameters = '{"tasks":[{"task":"move", "mode":"manual", "component":"tray","destination":{"predefined_pose":"up"}}],"initializer":{"device_type":"ui_pri","device_id":"ui_pri_101"}} ' 00041 00042 #json_parameters = "{\"tasks\":[{\"time_schedule\":1263798000000,\"task\":\"move\",\"destination\":{\"predefined_pose\":\"home\"}}],\"initializer\":{\"device_type\":\"ui_loc\",\"device_id\":\"ui_loc_0001\"}}" 00043 rospy.init_node('dm_client2') 00044 result = DM_client(json_parameters) 00045 rospy.loginfo('result %s',result) 00046 # print ("Result:" result) 00047 except rospy.ROSInterruptException: 00048 print "program interrupted before completion"