ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

Based on the insight given in a previous answer that this is possible because the tf::message_filter is just another message filter, I came up with the following working solution. Sync your tf::message_filter with one (or possibly both) your message_filter subscribers. pass the pointer to the resulting tf::message_filter to your synchronizer, and link you synchronizer to the callback. As in the following reworked .cpp code :

m_gpsSub= new message_filters::Subscriber<sensor_msgs::NavSatFix>(private_nh, "fix", 5);

  m_imuSub = new message_filters::Subscriber<sensor_msgs::Imu>(private_nh, "imu", 5);
  //m_gpsSub->connectInput(m_imuSub);
  m_gpsFilter = new tf::MessageFilter<sensor_msgs::NavSatFix>(*m_gpsSub, m_tfListener, odomFrameId, 10);

  sync= new message_filters::Synchronizer<MySyncPolicy>(MySyncPolicy(20), *m_gpsFilter,  *m_imuSub );
  //m_gpsFilter->connectInput(sync);
  sync->registerCallback(boost::bind(&SwarmbotMCL::gpsCallback, this, _1, _2));

Based on the insight given in a previous answer that this is possible because the tf::message_filter is just another message filter, I came up with the following working solution. Sync your tf::message_filter with one (or possibly both) your message_filter subscribers. pass the pointer to of the resulting tf::message_filter to your synchronizer, and link you synchronizer to the callback. As in the following reworked .cpp code :

m_gpsSub= new message_filters::Subscriber<sensor_msgs::NavSatFix>(private_nh, "fix", 5);

  m_imuSub = new message_filters::Subscriber<sensor_msgs::Imu>(private_nh, "imu", 5);
  //m_gpsSub->connectInput(m_imuSub);
  m_gpsFilter = new tf::MessageFilter<sensor_msgs::NavSatFix>(*m_gpsSub, m_tfListener, odomFrameId, 10);

  sync= new message_filters::Synchronizer<MySyncPolicy>(MySyncPolicy(20), *m_gpsFilter,  *m_imuSub );
  //m_gpsFilter->connectInput(sync);
  sync->registerCallback(boost::bind(&SwarmbotMCL::gpsCallback, this, _1, _2));