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

turtlesim velocity units?

asked 2012-01-03 08:44:04 -0500

Paul0nc gravatar image

updated 2012-01-03 08:44:28 -0500

Can anyone tell me how to correlate a velocity message to turtlesim with its actual motion? In particular, I'm currently trying to get a specific rotation. I had assumed that sending a velocity message with angular=1 meant 1 radian per second for one second = 1 radian of rotation. Instead, I get something less than significantly less than this.

Using electric with ubuntu 10.4.

Thanks, Paul.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-01-03 10:27:09 -0500

mmwise gravatar image

updated 2012-01-05 09:17:06 -0500

You are correct. The turtle moves in radians per second. So if you command your turtle to move at 6.28 rad/sec it will make one full revolution in 1 second. You can test this out by using this command since the turtle executes commands for 1 second it will make 1 revolution.

pub -1 /turtle1/command_velocity turtlesim/Velocity  0.0  6.28

EDIT: To command the turtle propgramatically in C++ you will need to repeatedly publish the command velocity until you achieve the desired angle because the turtle times out the velocity commands after 1 second if it does not receive a new command within that time window.

A good example of commanding the turtle in C++ is the turtle_actionlib package ( The action server drives the turtle in a polygonal shape.

The turtle_actionlib draws regular polygons, the goal shown below takes in the number of sides and the radius of the circumscribed circle. When a goal is received, the goalCB() function computes the interior angles and apothem which are returned in the result in the action msg. Once a goal is received and the angles computed the controlCB() function publishes the velocity commands to draw the shape. Look in the shape_client.cpp file for how to send a goal to the shape_server.

#goal definition
int32 edges
float32 radius
#result definition
float32 interior_angle
float32 apothem

You should not need to change the command duration. The point of having a timeout is so that the turtle behaves more like robots in the real world where you need to publish msgs at a steady rate to continue moving.

edit flag offensive delete link more


Thanks mwise_wg. I'm trying to do it programmatically. Is there any timer built into the command that I might need to implement in a C++ program?
Paul0nc gravatar image Paul0nc  ( 2012-01-04 04:39:10 -0500 )edit
Again, thanks. Is it possible to use the turtle_actionlib to generate shapes besides the pentagon example? I'm not seeing how the actionlib actually takes a shape input. Also, is it possible to change the command duration? I tried altering the WallDuration(1.0) in turtle.cpp... but no luck.
Paul0nc gravatar image Paul0nc  ( 2012-01-05 08:51:52 -0500 )edit

Question Tools


Asked: 2012-01-03 08:44:04 -0500

Seen: 2,057 times

Last updated: Jan 05 '12