test_client_json_sep_2012.py
Go to the documentation of this file.
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":"fetch","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\":[{\"time_schedule\":1263798000000,\"task\":\"move\",\"destination\":{\"predefined_pose\":\"home\"}}],\"initializer\":{\"device_type\":\"ui_loc\",\"device_id\":\"ui_loc_0001\"}}"
00039         rospy.init_node('dm_client2')
00040         result = DM_client(json_parameters)
00041         rospy.loginfo('result %s',result)
00042         # print ("Result:" result)
00043     except rospy.ROSInterruptException:
00044         print "program interrupted before completion"


srs_decision_making
Author(s): Renxi Qiu
autogenerated on Mon Oct 6 2014 08:38:32