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


actionlib_tutorials
Author(s): Melonee Wise
autogenerated on Wed Mar 2 2022 00:05:48