multiple subscriber to single callback function not working
I am trying to subscribe to two topics of type ros_arduino_msgs/Digital
type in a single callback function like below:
#include <message_filters/subscriber.h>
#include <message_filters/time_synchronizer.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>
#include <iostream>
#include <ros_arduino_msgs/Digital.h>
using namespace ros_arduino_msgs;
using namespace message_filters;
void callback(const DigitalConstPtr& e1, const DigitalConstPtr& e2)
{
std::cout<<"callback"<<std::endl;
std::cout<<e1<<std::endl;
}
int main(int argc, char** argv)
{
ros::init(argc, argv, "vision_node");
std::cout<<"main"<<std::endl;
ros::NodeHandle nh;
message_filters::Subscriber<Digital> e1(nh, "/arduino/sensor/left_encoder_A", 10);
message_filters::Subscriber<Digital> e2(nh, "/arduino/sensor/left_encoder_B", 10);
TimeSynchronizer<Digital, Digital> sync(e1, e2, 10);
sync.registerCallback(boost::bind(&callback, _1, _2));
ros::spin();
return 0;
}
But when i run it is not working. Cant't i use type of subscirbed topic as arduino_ros_msgs/Digital, does it only works with ros msgs types like sensor msgs and std_msgs?