fibonacci_client.cpp
Go to the documentation of this file.
1 #include <ros/ros.h>
4 #include <actionlib_tutorials/FibonacciAction.h>
5 
6 int main (int argc, char **argv)
7 {
8  ros::init(argc, argv, "test_fibonacci");
9 
10  // create the action client
11  // true causes the client to spin its own thread
13 
14  ROS_INFO("Waiting for action server to start.");
15  // wait for the action server to start
16  ac.waitForServer(); //will wait for infinite time
17 
18  ROS_INFO("Action server started, sending goal.");
19  // send a goal to the action
20  actionlib_tutorials::FibonacciGoal goal;
21  goal.order = 20;
22  ac.sendGoal(goal);
23 
24  //wait for the action to return
25  bool finished_before_timeout = ac.waitForResult(ros::Duration(30.0));
26 
27  if (finished_before_timeout)
28  {
30  ROS_INFO("Action finished: %s",state.toString().c_str());
31  actionlib_tutorials::FibonacciResult result = *(ac.getResult());
32  std::stringstream result_string;
33  std::copy(result.sequence.begin(), result.sequence.end(),
34  std::ostream_iterator<int>(result_string, " "));
35  ROS_INFO("Action result: %s", result_string.str().c_str());
36  }
37  else
38  ROS_INFO("Action did not finish before the time out.");
39 
40  //exit
41  return 0;
42 }
fibonacci_client.result
def result
Definition: fibonacci_client.py:41
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
ros.h
actionlib::SimpleActionClient::waitForServer
bool waitForServer(const ros::Duration &timeout=ros::Duration(0, 0)) const
terminal_state.h
actionlib::SimpleClientGoalState
actionlib::SimpleActionClient
simple_action_client.h
actionlib::SimpleActionClient::sendGoal
void sendGoal(const Goal &goal, SimpleDoneCallback done_cb=SimpleDoneCallback(), SimpleActiveCallback active_cb=SimpleActiveCallback(), SimpleFeedbackCallback feedback_cb=SimpleFeedbackCallback())
actionlib::SimpleActionClient::getResult
ResultConstPtr getResult() const
actionlib::SimpleActionClient::waitForResult
bool waitForResult(const ros::Duration &timeout=ros::Duration(0, 0))
main
int main(int argc, char **argv)
Definition: fibonacci_client.cpp:6
actionlib::SimpleClientGoalState::toString
std::string toString() const
actionlib::SimpleActionClient::getState
SimpleClientGoalState getState() const
ROS_INFO
#define ROS_INFO(...)
ros::Duration


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