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

Moving Turtlebot to a goal without a map

asked 2013-06-24 23:04:54 -0600

lascre gravatar image

updated 2013-11-18 16:57:18 -0600

tfoote gravatar image

Hi there! We're two newbies. We installed Ros Electric on a pc acer aspire 5740g running Ubuntu Lucid 10.04. Our task is to move Turtlebot giving vocal commands. We're doing it writing publishers and subscribers in c++. We have a node which does the speech recognition, it publishes on a topic the identified word. When for example it publishes "advance" and "one", the turtlebot should move forward for one meter and then stop, waiting for new commands. We have to make the turtlebot do this without a map, only using odometry data. Our problem is that turtlebot doesn't stop after it has reached the goal.

To give you an idea of what we're doing, here's part of the code:

geometry_msgs::PoseWithCovarianceStamped msg; double pos_x,pos_y,pos_z,ori_x,ori_y,ori_z,ori_w;

void odomcallback(const geometry_msgs::PoseWithCovarianceStamped msg_turtlebot) { msg=msg_turtlebot; pos_x=msg.pose.pose.position.x; pos_y=msg.pose.pose.position.y; pos_z=msg.pose.pose.position.z; ori_x=msg.pose.pose.orientation.x; ori_y=msg.pose.pose.orientation.y; ori_z=msg.pose.pose.orientation.z; ori_w=msg.pose.pose.orientation.w; }

int main(int argc, char **argv) {
ros::init(argc, argv, "nodo_che_movimenta");
ros::NodeHandle node;
ros::Subscriber sub_odom = node.subscribe("odom", 1000, odomcallback);
ros::Publisher vel_pub = node.advertise<geometry_msgs::twist>("cmd_vel", 10);


geometry_msgs::Twist vel;
ros::Rate rate(10.0);
const double a=pos_x+1;

while (node.ok()) {
ros::spinOnce(); sostituto_quantita=quantita;
bool select=true;

if (attiva) {

[...] if(complesso==103 ) { printf("complesso_on\n"); printf("Inserisci quantità\n"); if(sostituto_quantita==1 && select==true) { printf("1 meter\n"); if(pos_x<a) {vel.linear.x="0.3;" vel.linear.y="vel.linear.z=0.0;" vel.angular.x="vel.angular.y=vel.angular.z=0.0;" }="" <br=""> else { select=false; } } [...]

rate.sleep(); }
return 0; }

edit retag flag offensive close merge delete


I think you forgot to stop publishing or to put vel.linear.x = 0.0 after you reached the goal.

Lucile gravatar image Lucile  ( 2013-06-24 23:57:31 -0600 )edit

We tried to put vel.linear.x=0 instead of the bool variable, but it didn't work. We suppose that the real problem is the condition we put in the if instruction: if(pos_x<a). It is always true since both pos_x and a continously update their values.

lascre gravatar image lascre  ( 2013-06-25 02:50:57 -0600 )edit

An easy way to find it out is to print 'a' value.

Lucile gravatar image Lucile  ( 2013-06-25 05:30:30 -0600 )edit

I am not sure weither it would work or not (I am using python and not C++ for ROS programming), but you could try to remove the ros::spin() and to use ros::spinOnce() at the end of your while loop.

Lucile gravatar image Lucile  ( 2013-06-25 22:35:23 -0600 )edit

We printed the values both of the odometry and of the target using the printf function and we found out that they don't change at all! Is this a loop? How to find out? We tried also to remove ros::spin() and use ros::spinOnce(), but it didn't serve. It still doesn't want to perform the task.l.

lascre gravatar image lascre  ( 2013-06-26 07:13:30 -0600 )edit

I just answered on the google group

Lucile gravatar image Lucile  ( 2013-06-26 22:14:42 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2013-11-12 09:00:17 -0600

sudhanshu_mittal gravatar image

updated 2013-11-12 09:04:58 -0600

For just moving the robot, without any information of the environment(map): Run the following command:

Topic Name: "/move_base_simple/goal"

Message Type: "geometry_msgs/PoseStamped"

rostopic pub /move_base_simple/goal geometry_msgs/PoseStamped '{ header: { frame_id: "base_link" }, pose: { position: { x: -1.0, y: 0 }, orientation: { x: 0, y: 0, z: 0, w: 1.0}}}'
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2013-06-24 23:04:54 -0600

Seen: 1,713 times

Last updated: Nov 12 '13