image_proc not publishing image_rect data after synchronizing camera_info

asked 2017-11-30 10:17:36 -0500

agog gravatar image

updated 2017-12-06 08:08:16 -0500

I have a camera driver without the camera_info topic. I am publishing this topic separately and synchronizing them with all the image_proc topics. I am getting data in image_mono and image_color but not in image_rect or image_rect_color topics. I am still getting a warning for non-synchronization.

[ WARN] [1512057285.359548566]: [image_transport] Topics '/camera/0/0/image_color' and '/camera/0/0/camera_info' do not appear to be synchronized. In the last 10s:
    Image messages received:      297
    CameraInfo messages received: 300
    Synchronized pairs:           0

Below is the sync node.

#include <message_filters/subscriber.h>
#include <message_filters/synchronizer.h>
#include <message_filters/sync_policies/approximate_time.h>
#include <sensor_msgs/Image.h>
#include <sensor_msgs/CameraInfo.h>
#include <ros/callback_queue.h>
#include <boost/bind.hpp>

using namespace sensor_msgs;
using namespace message_filters;

ros::Publisher image_raw_pub;
ros::Publisher image_mono_pub;
ros::Publisher image_color_pub;
ros::Publisher image_rect_pub;
ros::Publisher image_rect_color_pub;
ros::Publisher camera_info_pub;


void callback(const Image::ConstPtr& image1, const Image::ConstPtr& image2, const Image::ConstPtr& image3, const Image::ConstPtr& image4, const Image::ConstPtr& image5, const CameraInfo::ConstPtr& info)
{
  // Solve all of perception here...
  ROS_INFO("Sync_Callback");

  image_raw_pub.publish(image1);
  image_mono_pub.publish(image2);
  image_color_pub.publish(image3);
  image_rect_pub.publish(image4);
  image_rect_color_pub.publish(image5);
  camera_info_pub.publish(info);

}

int main(int argc, char** argv)
{
  ros::init(argc, argv, "camera_info_node");

  std::string img_raw_topic = "/camera/0/0/image_raw";
  std::string img_mono_topic = "/camera/0/0/image_mono";
  std::string img_color_topic = "/camera/0/0/image_color";
  std::string img_rect_topic = "/camera/0/0/image_rect";
  std::string img_rect_color_topic = "/camera/0/0/image_rect_color";
  std::string camera_info_topic = "/camera/0/0/camera_info";

  ros::NodeHandle nh;
  message_filters::Subscriber<Image> image_raw_sub(nh, img_raw_topic, 100);
  message_filters::Subscriber<Image> image_mono_sub(nh, img_mono_topic, 100);
  message_filters::Subscriber<Image> image_color_sub(nh, img_color_topic, 100);
  message_filters::Subscriber<Image> image_rect_sub(nh, img_rect_topic, 100);
  message_filters::Subscriber<Image> image_rect_color_sub(nh, img_rect_color_topic, 100);
  message_filters::Subscriber<CameraInfo> camera_info_sub(nh, camera_info_topic, 100);

  image_raw_pub = nh.advertise<Image>(img_raw_topic, 1000);
  image_mono_pub = nh.advertise<Image>(img_mono_topic, 1000);
  image_color_pub = nh.advertise<Image>(img_color_topic, 1000);
  image_rect_pub = nh.advertise<Image>(img_rect_topic, 1000);
  image_rect_color_pub = nh.advertise<Image>(img_rect_color_topic, 1000);
  camera_info_pub = nh.advertise<CameraInfo>(camera_info_topic, 1000);

  typedef sync_policies::ApproximateTime<Image, Image, Image, Image, Image, CameraInfo> MySyncPolicy;
  // ApproximateTime takes a queue size as its constructor argument, hence MySyncPolicy(10)
  Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), image_raw_sub, image_mono_sub, image_color_sub, image_rect_sub, image_rect_color_sub, camera_info_sub);
  sync.registerCallback(boost::bind(&callback, _1, _2, _3, _4, _5, _6));


  ros::spin();

  return 0;
}

EDIT:

On synchronizing only image_raw, image_mono and camera_info, the warning message is removed. However, the image_rect and image_rect_color still does not publish anything. Note: The two topics are being subscribed but no messages are being published.

edit retag flag offensive close merge delete