Question about sending simple goal to navigation stack.
I read this answer about how to publish /move_base_simple/goal. But I want to do something further.
Here is my current setup:
First ran:
roslaunch turtlebot_bringup minimal.launch
roslaunch turtlebot_navigation amcl_demo_rplidar.launch map_file:=/home/ubuntu/maps/mymap.yaml
then I try to publish the goals:
rostopic pub /move_base_simple/goal geometry_msgs/PoseStamped '{header: {stamp: now, frame_id: "map"}, pose: {position: {x: 1.0, y: 0.0, z: 0.0}, orientation: {w: 1.0}}}'
The robot moved.
Then I tried to do something further, so I wrote a node to publish the msg. Here is my code.
#include "std_msgs/String.h"
#include<ros/ros.h>
#include<geometry_msgs/PoseStamped.h>
#include <sstream>
int main(int argc, char **argv)
{
ros::init(argc, argv, "pub_goal");
ros::NodeHandle nh;
ros::Publisher pub = nh.advertise<geometry_msgs::PoseStamped>("/move_base_simple/goal",1) ;
ros::Rate loop_rate(1);
int count = 0;
while (ros::ok())
{
geometry_msgs::PoseStamped goal;
goal.header.frame_id="map";
goal.pose.position.x=1;
goal.pose.orientation.w=1;
goal.pose.orientation.z=0;
ROS_INFO("%lf",goal.pose.position.x);
pub.publish(goal);
ros::spinOnce();
loop_rate.sleep();
}
return 0;
}
After actkin_make, I rosrun it, but something wired happened.
Here is the result:
luc@luc-ThinkPad-T450:~/catkin_ws$ rosrun goal_test publish_goal
[ INFO] [1510794351.286271377]: 1.000000
[ INFO] [1510794352.286323753]: 1.000000
[ INFO] [1510794353.286425226]: 1.000000
[ INFO] [1510794354.286430381]: 1.000000
[ INFO] [1510794355.286429147]: 1.000000
[ INFO] [1510794356.286306929]: 1.000000
But the turtlebot2 is still.
Then I cancel the process by "ctrl+c", the turtlebot2 moved.
So, I am confused.
Could anyone please tell me how to publish a msg through a node to send simple goal to make my turtlebot2 move?
Sorry for my poor English.
Could it be that you send new goals so fast that the navigation stack is still calculating the old goal when it gets replaced by a new one?
@Humpelstilzchen: that is most likely the case, yes.
@LucYang:
move_base
is going to need some time to plan new trajectories and start moving the robot. It probably cannot do that in 1 second.Thank you! It is exactly the reason what you say.