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

group topics with diferent publishing rates

asked 2016-05-24 03:57:24 -0600

herimakil gravatar image

Hello there, i'm new into this community so sorry if I ask something dumb, tried to search first but could only find this and I don't understand it at all and don't know if it suits my problem answer.

Currently i'm working with a robot that publishes an enormous amount of topics. While the information it's usefull, for my client app that means a lot of overload in the conexion.

What I am trying to do so is, i'm building a node in the robot that will subscribe to the topics i really care about for the client, and publish them in a new personal msg type of my own that has only the parameters i need of those topics. for that i'm using an approach like this (subscriber and publisher in class).

Now, the real problem is that the topics i need are published at different rates, example: fcu/current_pose 60hz, flir/img 40hz.

Lets say i just want to publish when i have an image+current_pose that are at least very close in time, any idea ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-05-24 04:11:26 -0600

gvdhoorn gravatar image

Please see whether the ApproximateTime filter from the message_filters package works for you.

But just as in Synchronize two subscribed topics (btw, are these questions related?), if you just need to transform data from one frame to another, but in the past, then TF will automatically do that for you, provided you give it the correct timestamps.

edit flag offensive delete link more


wow, no actually i just saw that one after i registered :S

will try with message_filters since it has also an example, i will try work with that and see if it works.

with the TF you mean getting an actual location and move it back to match with the image?

herimakil gravatar image herimakil  ( 2016-05-24 04:26:07 -0600 )edit

with the TF you mean getting an actual location and move it back to match with the image?

yes. You don't need to 'move it back' yourself though, that is exactly what TF is for. It'll lookup the pose at a time in the past you provide, and then uses that to transform your data.

gvdhoorn gravatar image gvdhoorn  ( 2016-05-24 04:38:02 -0600 )edit

Please also see the Time travel with tf2 (Python or C++) tutorials.

gvdhoorn gravatar image gvdhoorn  ( 2016-05-24 04:39:14 -0600 )edit

one unrelated technical question (i found only problems about not processing in a fork and so.)

Since i will work with messages from various topics and convert them into another message type before publish, where should i process them before publish since it will take some time to process?

herimakil gravatar image herimakil  ( 2016-05-25 06:28:00 -0600 )edit

That is really actually a new question. If you are worried about throughput, you could consider making your callbacks thread safe and using an AsyncSpinner. Alternatively, you could look into maintaining a queue and a pool of workers (which is essentially the same, but you have more control).

gvdhoorn gravatar image gvdhoorn  ( 2016-05-25 06:46:29 -0600 )edit

that's what i am using

    ros::AsyncSpinner spinner(4); // Use 4 threads

while (ros::ok())

return 0;
herimakil gravatar image herimakil  ( 2016-05-26 03:20:31 -0600 )edit

Question Tools



Asked: 2016-05-24 03:57:24 -0600

Seen: 708 times

Last updated: May 24 '16