rsync_client_example.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #Based upon actionlib client tutorial
00003 #http://wiki.ros.org/actionlib_tutorials/Tutorials/Writing%20a%20Simple%20Action%20Client%20%28Python%29
00004 
00005 import rospy
00006 import roslib; roslib.load_manifest('rsync_ros')
00007 import actionlib
00008 import rsync_ros.msg
00009 import sys
00010 
00011 def rsync_client():
00012 
00013     # Creates the SimpleActionClient, passing the type of the action
00014     # (RsyncAction) to the constructor.
00015     client = actionlib.SimpleActionClient('rsync_ros', rsync_ros.msg.RsyncAction)
00016 
00017     # Waits until the action server has started up and started
00018     # listening for goals.
00019     client.wait_for_server()
00020 
00021     # Creates a goal to send to the action server.
00022     goal = rsync_ros.msg.RsyncGoal(rsync_args=sys.argv[1:-2], source_path=sys.argv[-2], destination_path=sys.argv[-1])
00023 
00024     # Sends the goal to the action server.
00025     client.send_goal(goal)
00026 
00027     # Waits for the server to finish performing the action.
00028     client.wait_for_result()
00029 
00030     # Prints out the result of executing the action
00031     return client.get_result()  # A RsyncResult
00032 
00033 if __name__ == '__main__':
00034     try:
00035         # Initializes a rospy node so that the SimpleActionClient can
00036         # publish and subscribe over ROS.
00037         rospy.init_node('rsync_client')
00038         result = rsync_client()
00039         print "Successful Transfer: {}".format(result.sync_success)
00040 
00041     except rospy.ROSInterruptException:
00042         print "program interrupted before completion"


rsync_ros
Author(s):
autogenerated on Thu Jul 21 2016 06:13:41