test_client_move_order.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 # Brings in the SimpleActionClient
00008 import actionlib
00009 
00010 # Brings in the messages used by the SRS DM action, including the
00011 # goal message and the result message.
00012 import srs_decision_making.msg as xmsg
00013 
00014 def DM_client(target_pos):
00015     # Creates the SimpleActionClient, passing the type of the action
00016     # constructor.
00017     client = actionlib.SimpleActionClient('srs_decision_making_actions', xmsg.ExecutionAction)
00018 
00019     # Waits until the action server has started up and started
00020     # listening for goals.
00021     client.wait_for_server()
00022 
00023     # Creates a goal to send to the action server.
00024     _goal=xmsg.ExecutionGoal()
00025     _goal.action="move"
00026     _goal.parameter=target_pos
00027     _goal.priority=0
00028     # Sends the goal to the action server.
00029     client.send_goal(_goal)
00030 
00031     # Waits for the server to finish performing the action.
00032     client.wait_for_result()
00033 
00034     # Prints out the result of executing the action
00035     return client.get_result()
00036 
00037 if __name__ == '__main__':
00038     try:
00039         # Initializes a rospy node so that the SimpleActionClient can
00040         # publish and subscribe over ROS.
00041         target_pos = sys.argv[1]
00042         print "moving to", target_pos
00043         rospy.init_node('dm_client2')
00044         result = DM_client(target_pos)
00045         rospy.loginfo('result %s',result)
00046         # print ("Result:" result)
00047     except rospy.ROSInterruptException:
00048         print "program interrupted before completion"


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