fibonacci_client.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 from __future__ import print_function
4 
5 import rospy
6 # Brings in the SimpleActionClient
7 import actionlib
8 
9 # Brings in the messages used by the fibonacci action, including the
10 # goal message and the result message.
11 import actionlib_tutorials.msg
12 
14  # Creates the SimpleActionClient, passing the type of the action
15  # (FibonacciAction) to the constructor.
16  client = actionlib.SimpleActionClient('fibonacci', actionlib_tutorials.msg.FibonacciAction)
17 
18  # Waits until the action server has started up and started
19  # listening for goals.
20  client.wait_for_server()
21 
22  # Creates a goal to send to the action server.
23  goal = actionlib_tutorials.msg.FibonacciGoal(order=20)
24 
25  # Sends the goal to the action server.
26  client.send_goal(goal)
27 
28  # Waits for the server to finish performing the action.
29  client.wait_for_result()
30 
31  # Prints out the result of executing the action
32  return client.get_result() # A FibonacciResult
33 
34 if __name__ == '__main__':
35  try:
36  # Initializes a rospy node so that the SimpleActionClient can
37  # publish and subscribe over ROS.
38  rospy.init_node('fibonacci_client_py')
39  result = fibonacci_client()
40  print("Result:", ', '.join([str(n) for n in result.sequence]))
41  except rospy.ROSInterruptException:
42  print("program interrupted before completion", file=sys.stderr)


actionlib_tutorials
Author(s): Melonee Wise
autogenerated on Wed Jun 5 2019 20:54:23