ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Sending map co-ordinates as goal to move_base

asked 2014-11-08 15:36:07 -0500

Ashwin27 gravatar image

updated 2014-11-09 11:20:41 -0500

I have an occupancy grid map and an exploration algorithm that provides me with 2 dimensional co-ordinates to travel to. The mapping and goal generation are working perfectly. Unfortunately, an error arises when I send the goal to move_base. The robot does not move and I get the following error:

The robot's start position is off the global costmap. Planning will always fail, are you sure the robot has been properly localized?

This is the part of the code that sends the goal:

MoveBaseClient ac("move_base", true); 
move_base_msgs::MoveBaseGoal goal; 
goal.target_pose.header.frame_id = "base_link"; 
goal.target_pose.header.stamp = ros::Time::now(); 
goal.target_pose.pose.position.x = goalx; 
goal.target_pose.pose.position.y = goaly;
goal.target_pose.pose.orientation.w = 1.0;     //Edit made based on David Lu's answer
ac.sendGoal(goal);

where goalx and goaly are integers that contain the map co-ordinates of the goal. MoveBaseClient has been defined earlier, as given in this link.

Also, if someone has links/documentation on move_base, quaternions in ROS or examples of sending goals to move_base apart from this tutorial link, please post them as well, I would be extremely grateful. I haven't perfectly understood how to programmatically send goals to move_base.

Thank You!

edit retag flag offensive close merge delete

Comments

1

goalx and goaly are map-coordinates. according to that you have to define the right frame_id:

goal.target_pose.header.frame_id = "/map";
lebowski gravatar image lebowski  ( 2014-11-10 10:35:08 -0500 )edit

hello @Ashwin27 , can I ask you about the goal generation algorithm that you used here? I had problems to find such algorithm for my experimental project. it would be very nice of you if u help me with it, thanks mate.

sobot gravatar image sobot  ( 2015-03-24 15:28:23 -0500 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2014-12-18 14:33:49 -0500

Ashwin27 gravatar image

Thank you, Lebowski and David. I modified the code as you guys suggested and solved the error.

goal_m.target_pose.header.frame_id = "/map";
goal_m.target_pose.header.stamp = ros::Time();

goal_m.target_pose.pose.position.x =mCurrentMap.getOriginX() + (((double)goal_x+0.5) * mCurrentMap.getResolution());

goal_m.target_pose.pose.position.y = mCurrentMap.getOriginY() + (((double)goal_y+0.5) * mCurrentMap.getResolution());

goal_m.target_pose.pose.orientation.w= 1.0;

edit flag offensive delete link more

Comments

Sorry to disturb you. But could you tell me to define the variable mCurrentMap, which header file shoul I use?

tanghz gravatar image tanghz  ( 2015-03-09 06:46:07 -0500 )edit

Quick question, how are you calculating the position.x ? you are doing origin.x + ((goal_x + 0.5)* resolution). What does the 0.5 stand for? I have a similar issue and in my case, position.x = (x coordinate * resolution) - origin.x.

RND gravatar image RND  ( 2015-03-26 09:50:36 -0500 )edit
1

answered 2014-11-08 16:40:19 -0500

David Lu gravatar image

Try adding goal.target_pose.pose.orientation.w = 1.0

edit flag offensive delete link more

Comments

Thanks for the reply, David! The quaternion error doesn't pop up anymore, but now it displays this error: The robot's start position is off the global costmap. Planning will always fail, are you sure the robot has been properly localized?

Ashwin27 gravatar image Ashwin27  ( 2014-11-09 11:18:33 -0500 )edit

I would look at the rviz output to see where the global costmap is relative to base_link.

David Lu gravatar image David Lu  ( 2014-11-09 14:20:03 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2014-11-08 15:36:07 -0500

Seen: 5,158 times

Last updated: Dec 18 '14