simple_navigation_goal.cpp
Go to the documentation of this file.
1 
6 #include <ros/ros.h>
7 #include <move_base_msgs/MoveBaseAction.h>
8 #include <actionlib/client/simple_action_client.h>
9 
10 typedef actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> MoveBaseClient;
11 
12 int main(int argc, char** argv){
13  ros::init(argc, argv, "simple_navigation_goals");
14 
15  //tell the action client that we want to spin a thread by default
16  MoveBaseClient ac("robot_0/move_base", true);
17 
18  //wait for the action server to come up
19  while(!ac.waitForServer(ros::Duration(5.0))){
20  ROS_INFO("Waiting for the move_base action server to come up");
21  }
22 
23  move_base_msgs::MoveBaseGoal goal;
24 
25  //we'll send a goal to the robot to move 1 meter forward
26  goal.target_pose.header.frame_id = "robot_0/map";
27  goal.target_pose.header.stamp = ros::Time::now();
28 
29  goal.target_pose.pose.position.x = 0.5;
30  goal.target_pose.pose.orientation.w = 1.0;
31 
32  ROS_INFO("Sending goal");
33  ac.sendGoal(goal);
34 
35  ac.waitForResult();
36 
37  if(ac.getState() == actionlib::SimpleClientGoalState::SUCCEEDED)
38  ROS_INFO("Hooray, the base moved 1 meter forward");
39  else
40  ROS_INFO("The base failed to move forward 1 meter for some reason");
41 
42  return 0;
43 }
MoveBaseClient
actionlib::SimpleActionClient< move_base_msgs::MoveBaseAction > MoveBaseClient
Definition: simple_navigation_goal.cpp:10
main
int main(int argc, char **argv)
Definition: simple_navigation_goal.cpp:12


rosinljubljana
Author(s): Igor Banfi
autogenerated on Mon Feb 24 2020 12:32:36