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


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