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

I want to subscribe to a limited number of header.frame_id topics in TF. [closed]

asked 2022-09-29 23:11:21 -0500

nemunatu gravatar image

Hello. When I subscribe to a TF topic in roscpp, I want to subscribe to only one particular header.frame_id topic among several header.frame_ids.

How can I do this?

Thanks.

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by nemunatu
close date 2022-10-11 03:10:49.103480

Comments

1

Instead of directly subscribing to /tf topic, please use tf API and let tf do the magic!

ravijoshi gravatar image ravijoshi  ( 2022-09-30 01:47:04 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-09-30 00:43:50 -0500

gvdhoorn gravatar image

updated 2022-10-01 03:02:44 -0500

I want to subscribe to a limited number of header.frame_id topics in TF. [..] How can I do this?

You can't.

ROS 1 does not support content based subscriptions. You either subscribe to a topic, or you don't. And if you do, it's the subscribers responsibility to filter out messages it isn't interested in.

Could you describe why you'd want to do this? You could have a valid use-case, but in general it's an anti-pattern to directly subscribe to /tf. That's the job of a tf2_ros::TransformListener. Retrieving a single transform would then be done by interrogating the associated tf2_ros::Buffer (using lookupTransform(..) for instance).

PS: pedantic, but:

I want to subscribe to only one particular header.frame_id topic [..]

header.frame_id is a field in the header field of a tf2_msgs/TFMessage message. The topics would be /tf and /tf_static.


Edit: from #q407180:

I asked this question [..] because the /tf topic delivers a transform for the camera position in addition to the AR marker transform, and I would like to subscribe to only one of the two topics.

To lookup a specific transform, you don't look at TFMessages directly. You'd use tf2_ros::Buffer::lookupTransform(..).

I'd recommend taking a look at the wiki/tf2/Tutorials, specifically Writing a tf2 listener (C++) (or the Python version). lookupTransform(..) is used here (Python version).

edit flag offensive delete link more

Comments

I see that I could not do it.

Thank you.

nemunatu gravatar image nemunatu  ( 2022-09-30 03:12:45 -0500 )edit

So what is it you actually want to do?

gvdhoorn gravatar image gvdhoorn  ( 2022-09-30 03:14:11 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-09-29 23:11:21 -0500

Seen: 54 times

Last updated: Oct 01 '22