How to subscribe to two images (ROS 2 and C++)
Hi.
I'm trying to use message_filters package (I also tried with image_transport...) to subscribe to two images. I couldn't understand the usage for ROS 2, but I found this short example for ROS 1. So, what changes do I need to do in this code to have it running in ROS 2?
Thanks in advance.
using namespace sensor_msgs;
using namespace message_filters;
void callback(const ImageConstPtr& image, const ImageConstPtr& cam_info)
{
// Callback function...
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "vision_node");
ros::NodeHandle nh;
message_filters::Subscriber<Image> image_1(nh, "image_1", 1);
message_filters::Subscriber<Image> image_2(nh, "image_2", 1);
TimeSynchronizer<Image, Image> sync(image_sub, info_sub, 10);
sync.registerCallback(boost::bind(&callback, _1, _2));
ros::spin();
return 0;
}