0
$\begingroup$

Rosanswers logo

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.


Originally posted by Paul0nc on ROS Answers with karma: 271 on 2012-01-03

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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 (http://ros.org/wiki/turtle_actionlib). 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
---
#feedback

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.


Originally posted by mmwise with karma: 8372 on 2012-01-03

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Paul0nc on 2012-01-05:
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.

Comment by Paul0nc on 2012-01-04:
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?

$\endgroup$

Your Answer

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