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

How to move turtlebot for a certain pre-defined distance

asked 2013-04-10 02:27:09 -0500

Anis gravatar image


We would like to write a code that makes Turtlebot move linearly to a specified distance, for example 2.3 meters.

We would like to know what will be the best strategy to implement this?

One way that we thought about is to send a constant linear velocity on topic twist.twist.linear.x and stops after a certain time t such as t=distance/velocity. Is this a good approach?

is there any other better strategy?

Thanks Anis

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-04-18 19:06:34 -0500

fergs gravatar image

One approach that is slightly better than timing is to use TF to see how far you've gone. One example I know of is using TF to measure angle in an older piece of code we used to draw a square on the ground using a TurtleBot. Doing a distance comparison should be even easier than angle comparison. In a straight line, the odometry of a Turtlebot shouldn't be too bad so TF should provide a more repeatable distance than timing (especially over longer distances at slower speeds).

edit flag offensive delete link more


Broken link

arpit901 gravatar image arpit901  ( 2016-06-06 10:12:49 -0500 )edit

answered 2013-04-10 03:58:17 -0500

prasanna.kumar gravatar image

updated 2013-04-10 04:02:01 -0500

You can send simple goals using MoveBaseAction. It's perfectly explained here. In the sample program, you can use 2.3 instead of 1 for goal.target_pose.pose.position.x or y. That should do!

edit flag offensive delete link more


Thanks. Yes, it will work, but needs navigation stack. I tried my solution above and it worked for moving forward and backward. However, for turning an angle, it does not give satisfactory results as the angle rotated is smaller than expected

Anis gravatar image Anis  ( 2013-04-11 03:54:40 -0500 )edit

Question Tools


Asked: 2013-04-10 02:27:09 -0500

Seen: 3,067 times

Last updated: Apr 18 '13