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

Sending goal to Navigation stack using simple_navigation_goals

asked 2014-01-21 18:10:30 -0500

Mercy gravatar image

updated 2014-01-22 02:11:34 -0500

I have gone through the tutorial where goals has been sent to navigation stack through simple_navigation_goals.

My question is using simple_navigation_goals, we can move a robot 1 meter forward, is there any provision in the package to move to a particular goal location (x,y)?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-01-22 03:50:26 -0500

Marcus gravatar image

Okay, I am really new to ROS but here we go.

I wrote a simple function which sends a new goal every time the previously send goal was reached: -->cpp file

bool Costmap_Movement_Class::SetNewGoal(const float &x, const float &y, const float &angle)
{
while(!this->m_ac.waitForServer(ros::Duration(5.0)))
{
    ROS_INFO("Costmap movement controller:...Waiting for the move_base action server");
}
move_base_msgs::MoveBaseGoal goal;
goal.target_pose.header.frame_id = "map"; //instead of base_link //map
goal.target_pose.header.stamp = ros::Time::now();

goal.target_pose.pose.position.x = x;
goal.target_pose.pose.position.y = y;
goal.target_pose.pose.orientation.w = angle;
ROS_INFO("Costmap movement controller:...Sending goal");
this->m_ac.sendGoal(goal);

return true;
}

-->header file

Costmap_Movement_Class():m_ac("move_base", true){};//constructor

Before the constructor I declare "m_ac" like this

m_MoveBaseClient m_ac;

And further you will need to include the necessary libraries

#include <ros/ros.h>
#include <move_base_msgs/MoveBaseAction.h>
#include <actionlib/client/simple_action_client.h>

Make sure to give these packages to the package.xml file and the cmakelist.txt otherwise the necessary header cannot be included.

The example might be a bit confusing at first, but if you read through it a second time I am sure you ll see how it works.

Furthermore I found that with

if(this->m_ac.getState() == actionlib::SimpleClientGoalState::SUCCEEDED)

You can get confirmation if your goal was reached.

Best of luck Marcus

edit flag offensive delete link more

Comments

@Marcus, thanks for the code. I observe that you have changed three things with respect to conventional simple_navigation_goals.cpp apart from adding the constructor. 1. map, have you faced any problem base_link? 2. Instead of meters, you used x and y co-ordinate. 3. If I choose 0 for angle does it move straight? How angle property will behave?

Mercy gravatar image Mercy  ( 2014-01-22 05:34:33 -0500 )edit

Like I said, I am merely an amateur with this stuff. 1.) I changed to map instead of base_link because the robot stop moving after reaching my first goal position. Through try and error (and because map is my "absolute" frame) I found that the robot will behave correctly. 2.) x,y, angle are basically the pose of my goal with respect to my "absolute" frame. Furthermore, since I spawn the robot in the origin of the absolute frame you could still put a 1 like in the example and you would receive a 1 meter forward movement of the robot. 3.) As far as I understand the angle does not have much to do with the overall movement. It just presents the angle the robot is suppose to have when he reaches the goal (always in relation to your absolute frame) I hope that helped Marcus

Marcus gravatar image Marcus  ( 2014-01-22 20:37:46 -0500 )edit

Thanks @Marcus

Mercy gravatar image Mercy  ( 2014-01-23 17:57:11 -0500 )edit

[ERROR] [1390980336.654648784]: Quaternion has length close to zero... discarding as navigation goal [ WARN] [1390980854.732553329]: Could not get robot pose, cancelling reconfiguration [ WARN] [1390980855.533396832]: Costmap2DROS transform timeout. Current time: 1390980855.5334, global_pose stamp: 1390980832.2348, tolerance: 0.3000 [ERROR] [1390980855.642393966]: Extrapolation Error looking up robot pose: Unable to lookup transform, cache is empty, when looking up transform from frame [/base_footprint] to frame [/map]

Mercy gravatar image Mercy  ( 2014-01-28 05:57:05 -0500 )edit

@Marcus I get some warnings and errors as above. When we set 2D Nav goal through rviz, then 3 things appear in the terminal position (3 tuple),orientation (4 tuple) and angle. Does orientation in the code and this has anything common in between them. I try to achieve same goal through code as we do in rviz. Thank you..

Mercy gravatar image Mercy  ( 2014-01-28 06:03:45 -0500 )edit

Hmmm..In fact I never had this problem. The first Error( Quaternion has length close to zero... discarding as navigation goal) I only get, if the position I chose as a goal is already the position where the robot is currently located. Did you try sending the goal without rviz (in your cpp file)? Does that work?

Marcus gravatar image Marcus  ( 2014-01-29 01:26:30 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-01-21 18:10:30 -0500

Seen: 2,281 times

Last updated: Jan 22 '14