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

group topics with diferent publishing rates

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

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
1

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

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

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?

herimakil gravatar image herimakil  ( 2016-05-24 04:26:07 -0500 )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 -0500 )edit

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

gvdhoorn gravatar image gvdhoorn  ( 2016-05-24 04:39:14 -0500 )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 -0500 )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 -0500 )edit

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;
herimakil gravatar image herimakil  ( 2016-05-26 03:20:31 -0500 )edit

Question Tools

3 followers

Stats

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

Seen: 715 times

Last updated: May 24 '16