Go to the documentation of this file.00001 #include <message_filters/subscriber.h>
00002 #include <message_filters/synchronizer.h>
00003 #include <message_filters/sync_policies/approximate_time.h>
00004 #include <sensor_msgs/Range.h>
00005 #include <iostream>
00006
00007 using namespace sensor_msgs;
00008 using namespace message_filters;
00009
00010 void callback(const RangeConstPtr& image1, const RangeConstPtr& image2)
00011 {
00012 std::cout << "hello" << std::endl;
00013
00014 }
00015
00016 int main(int argc, char** argv)
00017 {
00018 ros::init(argc, argv, "vision_node");
00019
00020 ros::NodeHandle nh;
00021 message_filters::Subscriber<Range> image1_sub(nh, "/robot0/sonar_0", 1);
00022 message_filters::Subscriber<Range> image2_sub(nh, "/robot0/sonar_1", 1);
00023
00024 typedef sync_policies::ApproximateTime<Range, Range> MySyncPolicy;
00025
00026 Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), image1_sub, image2_sub);
00027 sync.registerCallback(boost::bind(&callback, _1, _2));
00028
00029 ros::spin();
00030
00031 return 0;
00032 }