I try to use 'message_filters' to sync two topics which is published from gazebo simulator.
But it doesn't work fine :(
There is my code below:
my_node.cpp
#include "ros/ros.h"
#include
#include
#include
#include
#include "pkgA/msgA.h"
#include "pkgB/msgB.h"
void callback(const pkgA::msgA &a, const pkgB::msgB &b)
{
// Solve all of perception here...
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "gazebo_relay_node");
ros::NodeHandle nh;
message_filters::Subscriber subA(nh, "topicA", 1);
message_filters::Subscriber subB(nh, "topicB", 1);
TimeSynchronizer sync(subA, subB, 100);
sync.registerCallback(boost::bind(&callback, _1, _2));
ros::spin();
return 0;
}
I also tried 'approximate_time' and 'exact_time', but does not work, either.
There is a problem that I did a experiment:
I opened new terminal and published topics by manual, like:
> $ rostopic pub "/topicA" pkgA/msgA "" -r 10
> $ rostopic pub "/topicB" pkgB/msgB "" -r 10 Then 'my_node' worked very well.
**It just can not sync the topics from gazebo.**
> $ rostopic pub "/topicB" pkgB/msgB "" -r 10 Then 'my_node' worked very well.
**It just can not sync the topics from gazebo.**