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

Using Approximate Time Sync - how does it work?

asked 2013-05-24 03:32:38 -0500

101010 gravatar image

updated 2017-10-04 08:10:16 -0500

130s gravatar image

Greetings,

take this for instance:

int main(int argc, char** argv){

    ros::init(argc, argv, "decision_ensemble");
    DecisionEnsemble ensemble;
    ros::NodeHandle nh;
    message_filters::Subscriber<elars::alg1> alg1_sub(nh, "alg1", 1);
    message_filters::Subscriber<elars::alg2> alg2_sub(nh, "alg2", 1);
    message_filters::Subscriber<elars::alg3> alg3_sub(nh, "alg3", 1);
    ROS_INFO("HERE");
    typedef sync_policies::ApproximateTime<elars::alg1, elars::alg2, elars::alg3> syncPolicy;
    Synchronizer<syncPolicy> sync(syncPolicy(10), alg1_sub, alg2_sub, alg3_sub);
    sync.registerCallback(boost::bind(&DecisionEnsemble::ensembleCallback, &ensemble, _1, _2, _3));
    ros::spin();
    eturn 0;
}

An attempt to use ApproximateTime to synchronize 3 separate recognition algorithm messages. As you might expect, it doesn't work, simple hangs. The subscriptions are correct and I am sure that the 3 separate nodes are publishing, however, my callback for this particular node, ensemble callback, does not execute. In fact, the node hangs after subscribing to the topics alg1, alg2, alg3. Am I using boost::bind correctly? The template is a bit esoteric to the uninitiated.

In any event, the real question is this:

I have 3 nodes, each one taking some delta time interval to complete a task. I have an algorithm that needs info from each node, yet I do not want to run the algorithm until each of the 3 nodes have published. Once all 3 have published, I run the algorithm and output some interesting bit of data. The 3 algorithms are not synchronized and each can take wildly varying time to complete. Is ApproximateTime Synch the appropriate solution? or should I be investigating another approach to message passing synchronization?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-04-25 08:22:23 -0500

dim_sgou gravatar image

The lines that need to change

 message_filters::Subscriber<elars::alg1> *alg1_sub = new message_filters::Subscriber<elars::alg1(nh, "alg1", 1);
 message_filters::Subscriber<elars::alg2> *alg2_sub = new message_filters::Subscriber<elars::alg2>(nh, "alg2", 1);
 message_filters::Subscriber<elars::alg3> *alg3_sub = new message_filters::Subscriber<elars::alg3>(nh, "alg3", 1);
Synchronizer<syncPolicy> sync(syncPolicy(10), *alg1_sub, *alg2_sub, *alg3_sub);
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-05-24 03:32:38 -0500

Seen: 3,165 times

Last updated: Oct 04 '17