Hello, I am trying to synchronize the callbacks for two topics, one of them, a geometry_msgs::PoseStamped message that acts as a signal for image capture from another computer (just using PoseStamped as a test case for now because it comes with a timestamp, will write own message type later on), and then the actual image topic of type sensor_msgs::Image. This is the code snippet that's doing the approximate time synchronization.
void callback(const geometry_msgs::PoseStamped& signal, const sensor_msgs::ImageConstPtr& rightimage)
{
ROS_INFO("Reached callback");
cv_bridge::CvImagePtr imgPtr;
std::stringstream imgPath;
//More code
}
typedef sync_policies::ApproximateTime<geometry_msgs::PoseStamped, sensor_msgs::Image> ApproxSyncPol;
Subscriber<geometry_msgs::PoseStamped> signal_sub(nh, "/signal", 1);;
Subscriber<sensor_msgs::Image> image_sub(nh, "camera/image_mono", 1);
Synchronizer<ApproxSyncPol> syncPol(ApproxSyncPol(10), signal_sub, image_sub);
syncPol.registerCallback(boost::bind(&callback, _1, _2));
This code fails to compile with a lot of errors, mostly relating to boost and the Approximate Time sync_policies statement. An excerpt:
/opt/ros/indigo/include/message_filters/signal9.h:273:23: required from ‘message_filters::Connection message_filters::Signal9<M0, M1, M2, M3, M4, M5, M6, M7, M8>::addCallback(C&) [with C = const boost::_bi::bind_t<void, void (*)(const geometry_msgs::PoseStamped_<std::allocator<void> >&, const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&), boost::_bi::list2<boost::arg<1>, boost::arg<2> > >; M0 = geometry_msgs::PoseStamped_<std::allocator<void> >; M1 = sensor_msgs::Image_<std::allocator<void> >; M2 = message_filters::NullType; M3 = message_filters::NullType; M4 = message_filters::NullType; M5 = message_filters::NullType; M6 = message_filters::NullType; M7 = message_filters::NullType; M8 = message_filters::NullType]’
/opt/ros/indigo/include/message_filters/synchronizer.h:310:40: required from ‘message_filters::Connection message_filters::Synchronizer<Policy>::registerCallback(const C&) [with C = boost::_bi::bind_t<void, void (*)(const geometry_msgs::PoseStamped_<std::allocator<void> >&, const boost::shared_ptr<const sensor_msgs::Image_<std::allocator<void> > >&), boost::_bi::list2<boost::arg<1>, boost::arg<2> > >; Policy = message_filters::sync_policies::ApproximateTime<geometry_msgs::PoseStamped_<std::allocator<void> >, sensor_msgs::Image_<std::allocator<void> > >]’
/usr/include/boost/bind/bind.hpp:313:34: error: invalid initialization of reference of type ‘const geometry_msgs::PoseStamped_<std::allocator<void> >&’ from expression of type ‘const boost::shared_ptr<const geometry_msgs::PoseStamped_<std::allocator<void> > >’
unwrapper<F>::unwrap(f, 0)(a[base_type::a1_], a[base_type::a2_]);
But this same structure works perfectly, if both topics are sensor_msgs::Image. I am not getting what I'm doing wrong here, because geometry_msgs::PoseStamped is a message that does contain a timestamp.
Originally posted by SaiHV on ROS Answers with karma: 275 on 2016-01-26
Post score: 0
Original comments
Comment by ahendrix on 2016-01-26:
This looks like a mismatch between the arguments for your callback and the arguments that the synchronizer is expecting to pass to the callback. Can you edit your question to include the callback function signature?