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

Programming style question: getting data from odometry or tf?

asked 2019-11-16 16:35:52 -0500

wintermute gravatar image

updated 2019-11-18 07:25:09 -0500

Hello,

I wrote the following two programs to get my robot move in a particular direction and distance.

https://github.com/altineller/rospilo...

and

https://github.com/altineller/rospilo...

where the first program subscribes to odometry topic, and the second program gets the position of the robot with a transform listener, more specifically with:

self.tf_listener.lookupTransform(self.odom_frame, self.base_frame, rospy.Time(0))

Both programs work equally good. This is more of a programming style question.

What are the pros/cons of each one, and which one is considered best practice?

The odometry could stop sendign messages. Is that the case with the tf?

I would like to choose one style for my future programs. Which one should I prefer?

Best Regards, C.A.

edit retag flag offensive close merge delete

Comments

The links that you've included return 404s, perhaps you can repost them?

jayess gravatar image jayess  ( 2019-11-18 00:11:43 -0500 )edit

hello, I have changed the links

wintermute gravatar image wintermute  ( 2019-11-18 07:25:51 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
4

answered 2019-11-17 13:52:12 -0500

Use TF.

The odom topic is going to be the raw output of your wheel encoders (or whatever the odometry source is). If you fuse multiple sensor sources together using something like robot_localization or robot_pose_ekf, its going to publish on TF the fused positioning.

Also if you want to ever get not just the current odometry information but information at a specific time (even if only 100ms ago) you're going to need to use TF or you need to buffer a bunch of measurements for "just in case". TF will store the buffer for you and also do interpolation between nearby measurements for a best-possible estimation.

Also the case you mention for odometry not publishing, you're dead in the water. TF will be valid as long as the transforms are valid at least.

edit flag offensive delete link more

Comments

thank you very much. I had decided to go with TF, because the topic based one has difficulty getting the initial values.

wintermute gravatar image wintermute  ( 2019-11-18 07:27:23 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2019-11-16 16:35:52 -0500

Seen: 289 times

Last updated: Nov 18 '19