Sending multiple Goals to robot by cpp code
after testing the sending a simpleGoal to my robot i based on http://wiki.ros.org/navigation/Tutori... and it working well i focus now on sending multiple goals when it reached the first one go to the second one ... it's possible if yes help with documentations or example NB: i am programming with cpp :)
Update:
i tried with this what do you think about it
#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;
bool one_move(move_base_msgs::MoveBaseGoal goal) {
goal.target_pose.header.frame_id = "base_link";
goal.target_pose.header.stamp = ros::Time::now();
ac.sendGoal(goal);
ac.waitForResult();
if(ac.getState() == actionlib::SimpleClientGoalState::SUCCEEDED)
return true;
else
return false;
}
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("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[3];
goal[0].target_pose.pose.position.x = 0.7783;
goal[0].target_pose.pose.position.y = -0.0390;
goal[0].target_pose.pose.position.z = 0.0;
goal[0].target_pose.pose.orientation.x = 0.0;
goal[0].target_pose.pose.orientation.y = 0.0;
goal[0].target_pose.pose.orientation.z = 0.0182;
goal[0].target_pose.pose.orientation.w = 0.99910;
goal[1].target_pose.pose.position.x = 0.7783;
goal[1].target_pose.pose.position.y = -0.0390;
goal[1].target_pose.pose.position.z = 0.0;
goal[1].target_pose.pose.orientation.x = 0.0;
goal[1].target_pose.pose.orientation.y = 0.0;
goal[1].target_pose.pose.orientation.z = 0.0182;
goal[1].target_pose.pose.orientation.w = 0.99910;
goal[2].target_pose.pose.position.x = 0.7783;
goal[2].target_pose.pose.position.y = -0.0390;
goal[2].target_pose.pose.position.z = 0.0;
goal[2].target_pose.pose.orientation.x = 0.0;
goal[2].target_pose.pose.orientation.y = 0.0;
goal[2].target_pose.pose.orientation.z = 0.0182;
goal[2].target_pose.pose.orientation.w = 0.99910;
//we'll send a goal to the robot to move 1 meter forward
ROS_INFO("Sending goal1");
for(int i=0; i<3; i++)
{
if(one_move(goal[i])
{
ROS_INFO("Hooray, the %f goal reached",i);
}
else
{
ROS_INFO("The the %f goal doesn't reached for some reason",i)
return 0;
}
}