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

Combining Approximate and Exact Time Synchronization Policies with message_filters

asked 2020-07-17 10:08:10 -0500

deepaktalwardt gravatar image

Is there a way to use both Approximate and Exact Time Synchronization policies together in a node?

Specifically, I have 3 topics - let's call them /a, /b and /c, carrying messages of types A, B and C respectively. I want /a, /b to be synchronized using message_filters::sync_policies::ApproximateTime<A, B> policy. And I want /b and /c to be synchronized using message_filters::TimeSynchronizer<B, C>. Basically, I expect A and B type messages to have approximately the same timestamps, but I know that B and C will definitely use the same timestamps, and I want to be certain that I'm accidentally not using C whose timestamp is not matching with B's. Is there a way to set this up with message_filters, or another way to solve this problem? Any help is appreciated! Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-07-18 10:52:33 -0500

kosmastsk gravatar image
message_filters::Subscriber<A> A_sub(nh, "/a", 1);
message_filters::Subscriber<B> B_sub(nh, "/b", 1);
message_filters::Subscriber<C> C_sub(nh, "/c", 1);

typedef sync_policies::ExactTime<A, B> MySyncPolicy1;
Synchronizer<MySyncPolicy1> sync1(MySyncPolicy1(10), a_sub, b_sub);

typedef sync_policies::ApproximateTime<B, C> MySyncPolicy2;
Synchronizer<MySyncPolicy2> sync2(MySyncPolicy2(10), b_sub, c_sub);

sync1.registerCallback(boost::bind(&callback1, _1, _2));
sync2.registerCallback(boost::bind(&callback2, _1, _2));

Does something like this solves your problem? Or you want to also combine the output of these filters?

edit flag offensive delete link more

Comments

Thanks for this! I was hoping that the messages would be available within the same callback function. Is that possible in some way? I guess I could store these as class variables from within the callbacks and use them in a third function, but I'm just wondering if there's a better way to do this? Thank you again!

deepaktalwardt gravatar image deepaktalwardt  ( 2020-07-20 11:37:20 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2020-07-17 10:08:10 -0500

Seen: 478 times

Last updated: Jul 18 '20