Robotics StackExchange | Archived questions

group topics with diferent publishing rates

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 ?

Asked by herimakil on 2016-05-24 03:57:24 UTC

Comments

Answers

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.

Asked by gvdhoorn on 2016-05-24 04:11:26 UTC

Comments

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?

Asked by herimakil on 2016-05-24 04:26:07 UTC

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.

Asked by gvdhoorn on 2016-05-24 04:38:02 UTC

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

Asked by gvdhoorn on 2016-05-24 04:39:14 UTC

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?

Asked by herimakil on 2016-05-25 06:28:00 UTC

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).

Asked by gvdhoorn on 2016-05-25 06:46:29 UTC

that's what i am using

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

while (ros::ok())
{
    SAPObject.publishReduced();
    loop_rate.sleep();
}

return 0;

Asked by herimakil on 2016-05-26 03:20:31 UTC