Typedefs | Functions
simple_navigation_goal.cpp File Reference
#include <ros/ros.h>
#include <move_base_msgs/MoveBaseAction.h>
#include <actionlib/client/simple_action_client.h>
Include dependency graph for simple_navigation_goal.cpp:

Go to the source code of this file.

Typedefs

typedef actionlib::SimpleActionClient< move_base_msgs::MoveBaseAction > MoveBaseClient
 

Functions

int main (int argc, char **argv)
 

Detailed Description

Example of sanding goal to move_base:

/*! \file simple_navigation_goal.cpp
 *  Example of sanding goal to move_base:
 *  \verbinclude simple_navigation_goal.cpp
 */

#include <ros/ros.h>
#include <move_base_msgs/MoveBaseAction.h>
#include <actionlib/client/simple_action_client.h>

typedef actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> MoveBaseClient;

int main(int argc, char** argv){
  ros::init(argc, argv, "simple_navigation_goals");

  //tell the action client that we want to spin a thread by default
  MoveBaseClient ac("robot_0/move_base", true);

  //wait for the action server to come up
  while(!ac.waitForServer(ros::Duration(5.0))){
    ROS_INFO("Waiting for the move_base action server to come up");
  }

  move_base_msgs::MoveBaseGoal goal;

  //we'll send a goal to the robot to move 1 meter forward
  goal.target_pose.header.frame_id = "robot_0/map";
  goal.target_pose.header.stamp = ros::Time::now();

  goal.target_pose.pose.position.x = 0.5;
  goal.target_pose.pose.orientation.w = 1.0;

  ROS_INFO("Sending goal");
  ac.sendGoal(goal);

  ac.waitForResult();

  if(ac.getState() == actionlib::SimpleClientGoalState::SUCCEEDED)
    ROS_INFO("Hooray, the base moved 1 meter forward");
  else
    ROS_INFO("The base failed to move forward 1 meter for some reason");

  return 0;
}

Definition in file simple_navigation_goal.cpp.

Typedef Documentation

◆ MoveBaseClient

typedef actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> MoveBaseClient

Definition at line 10 of file simple_navigation_goal.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 12 of file simple_navigation_goal.cpp.



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