actionlib-multiple-goals [closed]
Dear all.
I have a callback function, that every time is called, it sends goal coordinates to the move base.
Inside the callback function, MoveBaseClient ac("move_base", true); and waitForServer(ros::Duration(1.0) are called every time the call back function is called.
I am not sure if it is right to call these 2 functions every time the callback function is call.
Here is the piece of code of my call back function
void Pose_Goal::callback(nav_msgs::Odometry msg){
gx = msg.pose.pose.position.x;
gy = msg.pose.pose.position.y;
gz = msg.pose.pose.position.z;
MoveBaseClient ac("move_base", true);
//wait for the action server to come up
while(!ac.waitForServer(ros::Duration(1.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 = "base_link";
goal.target_pose.header.stamp = ros::Time::now();
goal.target_pose.pose.position.x = gx;
goal.target_pose.pose.position.y = gy;
goal.target_pose.pose.orientation = tf::createQuaternionMsgFromYaw(th);
ROS_INFO("Sending goal");
ac.sendGoal(goal);
ac.waitForResult();
if(ac.getState() == actionlib::SimpleClientGoalState::SUCCEEDED)
ROS_INFO("Hooray, the base moved x = %f, y = %f, i = %d", gx,gy,i);
}
In advance thank you for your kind help.
so do you got your navigation stack working?