Okay, I am really new to ROS but here we go.
I wrote a simple function which sends a new goal every time the previously send goal was reached:
-->cpp file
bool Costmap_Movement_Class::SetNewGoal(const float &x, const float &y, const float &angle)
{
while(!this->m_ac.waitForServer(ros::Duration(5.0)))
{
ROS_INFO("Costmap movement controller:...Waiting for the move_base action server");
}
move_base_msgs::MoveBaseGoal goal;
goal.target_pose.header.frame_id = "map"; //instead of base_link //map
goal.target_pose.header.stamp = ros::Time::now();
goal.target_pose.pose.position.x = x;
goal.target_pose.pose.position.y = y;
goal.target_pose.pose.orientation.w = angle;
ROS_INFO("Costmap movement controller:...Sending goal");
this->m_ac.sendGoal(goal);
return true;
}
-->header file
Costmap_Movement_Class():m_ac("move_base", true){};//constructor
Before the constructor I declare "m_ac" like this
m_MoveBaseClient m_ac;
And further you will need to include the necessary libraries
#include <ros/ros.h>
#include <move_base_msgs/MoveBaseAction.h>
#include <actionlib/client/simple_action_client.h>
Make sure to give these packages to the package.xml file and the cmakelist.txt otherwise the necessary header cannot be included.
The example might be a bit confusing at first, but if you read through it a second time I am sure you ll see how it works.
Furthermore I found that with
if(this->m_ac.getState() == actionlib::SimpleClientGoalState::SUCCEEDED)
You can get confirmation if your goal was reached.
Best of luck
Marcus