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

Best way to get Turtlebot's current velocity?

asked 2012-07-19 11:12:45 -0600

brianpen gravatar image

updated 2012-08-31 12:07:31 -0600

Hello all,

What's the best way to get the current velocity of the turtlebot?

I saw that I could listen to the Odom messages directly, or ask tf to getTwist(). Which method will give me the most accurate estimate? Or is there another way that's better?


I'm doing SLAM on a known map, so I have localization information.

What I ended up doing

Here's what I ended up doing after some trial and error. This example is using the tf_tutorials, but the real robot is similar. Just change "turtle" to "base_link" and "world" to "map". "lin" has the linear acceleration and "ang" has the angular. The velocity is relative to the world frame.

(trans, rot) = listener.lookupTransform('/world', turtle, rospy.Time(0.0))
(lin, ang) = listener.lookupTwistFull(turtle, '/world', turtle, (0,0,0), '/world', rospy.Time(0.0), rospy.Duration(0.1))

Thanks in advance, -Brian

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-07-19 11:26:49 -0600

cagatay gravatar image

updated 2012-07-19 11:31:47 -0600

Supposing that you are trying to perform SLAM, turtlebot publishes odom data but robot_pose_ekf sends the transform ( as odom_combined i think) which is the filtered version. I think that it is better for you to subscribe topics which robot_pose_ekf puslishes

edit flag offensive delete link more


As far as I can tell, robot_pose_ekf just publishes a geometry_msgs/PoseWithCovarianceStamped, which doesn't include velocity. Am I missing something?

brianpen gravatar image brianpen  ( 2012-07-19 11:36:57 -0600 )edit

dx/dt = v will give you the velocity i guess

cagatay gravatar image cagatay  ( 2012-07-19 11:51:12 -0600 )edit

I think tf's getTwist() does that for you and the ekf_robot_pose publishes an odom frame... so it's sounding like that's the way to do it. I was just wondering if there's a more direct way. Thanks for responding.

brianpen gravatar image brianpen  ( 2012-07-19 12:58:49 -0600 )edit

The odom topic published by turtlebot will give the instantaneous velocity as calculated by the wheel encoders. The pose topic published by robot_pose_ekf is a filtered result from all odometry inputs, so differentiating that over time will give a "filtered" (close to instantaneous) velocity value.

weiin gravatar image weiin  ( 2012-07-19 15:10:05 -0600 )edit

and if you use the localization value (/map->/base_link transform) and differentiate that, it would probably be an average velocity since the localization may have discrete jumps

weiin gravatar image weiin  ( 2012-07-19 15:12:38 -0600 )edit

Question Tools



Asked: 2012-07-19 11:12:45 -0600

Seen: 2,928 times

Last updated: Aug 31 '12