fibonacci_client.py
Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 
00003 from __future__ import print_function
00004 
00005 import rospy
00006 # Brings in the SimpleActionClient
00007 import actionlib
00008 
00009 # Brings in the messages used by the fibonacci action, including the
00010 # goal message and the result message.
00011 import actionlib_tutorials.msg
00012 
00013 def fibonacci_client():
00014     # Creates the SimpleActionClient, passing the type of the action
00015     # (FibonacciAction) to the constructor.
00016     client = actionlib.SimpleActionClient('fibonacci', actionlib_tutorials.msg.FibonacciAction)
00017 
00018     # Waits until the action server has started up and started
00019     # listening for goals.
00020     client.wait_for_server()
00021 
00022     # Creates a goal to send to the action server.
00023     goal = actionlib_tutorials.msg.FibonacciGoal(order=20)
00024 
00025     # Sends the goal to the action server.
00026     client.send_goal(goal)
00027 
00028     # Waits for the server to finish performing the action.
00029     client.wait_for_result()
00030 
00031     # Prints out the result of executing the action
00032     return client.get_result()  # A FibonacciResult
00033 
00034 if __name__ == '__main__':
00035     try:
00036         # Initializes a rospy node so that the SimpleActionClient can
00037         # publish and subscribe over ROS.
00038         rospy.init_node('fibonacci_client_py')
00039         result = fibonacci_client()
00040         print("Result:", ', '.join([str(n) for n in result.sequence]))
00041     except rospy.ROSInterruptException:
00042         print("program interrupted before completion", file=sys.stderr)


actionlib_tutorials
Author(s): Melonee Wise
autogenerated on Thu Jun 6 2019 21:11:25