Ask Your Question

geometry_msgs::Twist and cmd_vel on Turtlebot

asked 2012-05-08 08:24:09 -0500

McMurdo gravatar image

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!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-05-08 09:36:40 -0500

Mac gravatar image

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.

edit flag offensive delete link more


@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?

McMurdo gravatar image McMurdo  ( 2012-05-10 04:09:22 -0500 )edit

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.

Mac gravatar image Mac  ( 2012-05-10 07:06:39 -0500 )edit

@Mac I need to drive it to a particular point at a particular radius...

McMurdo gravatar image McMurdo  ( 2012-05-10 19:24:09 -0500 )edit

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.

Mac gravatar image Mac  ( 2012-05-11 03:45:35 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2012-05-08 08:24:09 -0500

Seen: 13,601 times

Last updated: May 10 '12