Rosanswers logo

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; }
else { select=false; } } [...]

rate.sleep(); }
return 0; }

Originally posted by lascre on ROS Answers with karma: 1 on 2013-06-24

Post score: 0

Original comments

Comment by Lucile on 2013-06-24:
I think you forgot to stop publishing or to put vel.linear.x = 0.0 after you reached the goal.

Comment by lascre on 2013-06-25:
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.

Comment by Lucile on 2013-06-25:
An easy way to find it out is to print 'a' value.

Comment by Lucile on 2013-06-25:
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.

Comment by lascre on 2013-06-26:
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.

Comment by Lucile on 2013-06-26:
I just answered on the google group


1 Answer 1


Rosanswers logo

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}}}'

Originally posted by sudhanshu_mittal with karma: 311 on 2013-11-12

This answer was ACCEPTED on the original site

Post score: 0


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.