Approximate time synchronizer for Different message Types
Hi everyone,
I am trying to incorporate message filtering in my code. I need to subscribe to two topics and execute the callback when both topics get a message at the same time (or approximately). This is what I wrote so far:
/// Subscribers to the two topics
typedef message_filters::Subscriber<sensor_msgs::Image> blobSubscriber;
typedef message_filters::Subscriber<std_msgs::Float32MultiArray> PCLSubscriber;
typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::Image, std_msgs::Float32MultiArray> sync_policy_classification;
void callback(const sensor_msgs::Image::ConstPtr& image, const std_msgs::Float32MultiArray::ConstPtr& object_coordinates)
{
// Some stuff here
}
int main(int argc, char **argv) {
ros::init(argc, argv, "colour_classification");
ros::NodeHandle n;
blobSubscriber blob_sub(n, "/object_detection/object_mask", 1);
PCLSubscriber PCL_sub(n, "/PCL_wooden_shape_recognition", 1);;
message_filters::Synchronizer<sync_policy_classification> class_sync(sync_policy_classification(10), blob_sub, PCL_sub);
class_sync.registerCallback(boost::bind(&callback, _1, _2));
return 0;
}
This is the part of my code that includes the message filtering stuff.
When I try to compile this I get a large number of errors, that have to do with the different types of the messages. I actually tried using sensor_msgs::Image for both messages and was able to compile without any issues.
So my question is: Is it actually possible to implement message filtering for different types of messages? And if yes, is there something obviously wrong with my code?
Thank you in advance!!!