actionlib-multiple-goals [closed]

asked 2013-06-13 06:06:35 -0500

acp gravatar image

updated 2013-06-13 10:20:13 -0500

joq gravatar image

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.

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2017-07-07 15:45:55.781785

Comments

so do you got your navigation stack working?

Gazer gravatar imageGazer ( 2013-06-13 14:22:44 -0500 )edit