Robotics StackExchange | Archived questions

Sending Multiple Goals to SendingSimpleGoals

Hello,

I am following this tutorial to send a goal for navigation.

I have modified the code to send multiple goals as oppose to one, below is the code I am using:


#include <ros/ros.h>

 #include <move_base_msgs/MoveBaseAction.h>

 #include <actionlib/client/simple_action_client.h>

 #include <iostream>

 #include <array>

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

int x [3] = {2, 2, 2}; 
int w [3] = {1, 1, 1};

int lenght0f_Array = sizeof(x) / sizeof(x[0]);


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;

  //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();

  for( int i = 0; i < lenght0f_Array; i = i + 1 ) {
    goal.target_pose.pose.position.x = x[i];
    goal.target_pose.pose.orientation.w = w[i];
    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;

}

When I try to do catkin_make, I get the error:

simple_navigation_goals/CMakeFiles/simple_navigation_goals.dir/build.make:62: recipe for target 'simple_navigation_goals/CMakeFiles/simple_navigation_goals.dir/src/simple_navigation_goals.cpp.o' failed
make[2]: *** [simple_navigation_goals/CMakeFiles/simple_navigation_goals.dir/src/simple_navigation_goals.cpp.o] Error 1
CMakeFiles/Makefile2:5500: recipe for target 'simple_navigation_goals/CMakeFiles/simple_navigation_goals.dir/all' failed
make[1]: *** [simple_navigation_goals/CMakeFiles/simple_navigation_goals.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 92%] Built target visp_hand2eye_calibration_client
[ 94%] Built target trackerNodelet
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

Does anyone know how to fix this error?

Thanks, Aaron


Update:

I noticed when I removed

#include iostream

#include array

It was then able to catkin_make without errors....why is that?

Asked by aarontan on 2018-06-16 15:20:12 UTC

Comments

Please don't use an image to display text. Images are not searchable and people cannot copy and paste the text from the image. Please update your question with a copy and paste of the text instead.

Asked by jayess on 2018-06-16 16:19:51 UTC

I have updated it

Asked by aarontan on 2018-06-16 16:28:19 UTC

Answers