Rosanswers logo

I need help in using geometry_msgs::Twist with cmd_vel on the TurtleBot.

I am not sure what the cmd_vel does when I send a message to it.

Someone please explain clearly what it does and how I can make it move to a particular point on the map. I can get the current pose of the turtlebot from the move_base/feedback topic for feedback.

Also I found out that the program "turtlebot_follower.cpp" (package - Kinnect Follower Demo) uses the same topic (cmd_vel) to control the motors. But, I could understand little from the code. The code was trying to equate a distance with velocity, though both are floats. Please try to explain the logic behind doing so, if possible.

Thank you!

Originally posted by McMurdo on ROS Answers with karma: 1247 on 2012-05-08

Post score: 2


1 Answer 1


Rosanswers logo

Mathematically, a "twist" is a six-dimensional velocity (see Wikipedia. The Twist message represents just such a velocity. By convention, robots listen on the /cmd_vel topic for Twist messages, and then respond appropriately. That is, you fill in a Twist message with the velocity values you want, and publish it to /cmd_vel. The robot (actually the ROS node that implements the hardware driver for your robot) listens on /cmd_vel and then translates the velocities in those messages into wheel speeds.

Of course, most robots can't travel in six degrees of freedom; the Turtlebot only has two (linear speed and angular speed), so most of the values are ignored.

Navigating to a particular point on a map is (in general) trickier than just setting a speed. If the world has no obstacles, it's two steps: 1) point the robot at the goal and 2) drive there. If there are obstacles, you should look into the navigation stack, which works just fine on a Turtlebot.

I don't know what you mean by "equate a distance with a velocity" (and I haven't had a chance to read that particular file). I do have a guess: if you're trying to follow something, you want to move faster the further away it is. Therefore, you set the robot's speed to some constant times the distance to the object; this gets you a smooth approach.

Originally posted by Mac with karma: 4119 on 2012-05-08

This answer was ACCEPTED on the original site

Post score: 9

Original comments

Comment by McMurdo on 2012-05-10:
@Mac I followed your method and succeeded to an extent. I can now point the robot at the goal and drive it there. I wanted to navigate the robot along a circle. So I used a program to generate the coordinates of such a circle and passed them one by one to the robot. It navigates the circle perfectly but it is very slow. When I try to control both the linear and angular velocities together, it fails miserably.

I want to navigate the circle at a moderate speed and in a smooth fashion. Can you please give me a direction in which I can proceed?

Comment by Mac on 2012-05-10:
Recall that the Twist message is a velocity, not a location; to drive in a circle, set a constant linear and angular speed, and send that message. If that doesn't work, you might have a different problem; I suggest starting a new question if that's the case.

Comment by McMurdo on 2012-05-10:
@Mac I need to drive it to a particular point at a particular radius...

Comment by Mac on 2012-05-11:
I'm not sure what you mean; if you want to drive to a specific world point ("Three meters to the left, six meters backwards"), that point doesn't have a radius. If you want to drive along a specific curve, setting the linear and angular does that.


Your Answer

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