Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Approximate time synchronizer, callback is not called

Hi,

My approximate time synchronizer with two topics (Camera and Liar) works fine. But When I add one more topic to it, my callback function seems never get called..

I am attaching the codes below for help. First node is the time synchronizer and second node is additional topic that I want to synchronize with other two topics (camera and lidar).

Thank you in advance.

ros::Publisher image1_pub; ros::Publisher image2_pub; ros::Publisher image3_pub;

void callback(const sensor_msgs::Image::ConstPtr& image1, const sensor_msgs::PointCloud2::ConstPtr& image2, const sensor_msgs::PointCloud2::ConstPtr& image3) {

ROS_INFO("Sync_Callback");

image1_pub.publish(image1);

image2_pub.publish(image2);

image3_pub.publish(image3);

}

int main(int argc, char** argv) {

ros::init(argc, argv, "TimeSynchronizer");

std::string zed1_img_topic = "/zed/right/image_rect_color";

std::string zed2_img_topic = "/velodyne_points";

std::string zed3_img_topic = "/chatter";

ros::NodeHandle nh;

message_filters::Subscriber<sensor_msgs::image> image1_sub(nh, zed1_img_topic, 1);

message_filters::Subscriber<sensor_msgs::pointcloud2> image2_sub(nh, zed2_img_topic, 1);

message_filters::Subscriber<sensor_msgs::pointcloud2> image3_sub(nh, zed3_img_topic, 1);

image1_pub = nh.advertise<sensor_msgs::image>("/synchronized" + zed1_img_topic, 1000);

image2_pub = nh.advertise<sensor_msgs::pointcloud2>("/synchronized" + zed2_img_topic, 1000);

image3_pub = nh.advertise<sensor_msgs::pointcloud2>("/synchronized" + zed3_img_topic, 1000);

typedef sync_policies::ApproximateTime<image, pointcloud2,="" pointcloud2=""> MySyncPolicy;

Synchronizer<mysyncpolicy> sync(MySyncPolicy(10), image1_sub, image2_sub, image3_sub);

sync.registerCallback(boost::bind(&callback, _1, _2, _3));

ros::spin();

return 0;

}

int main (int argc, char **argv){

ros::init(argc, argv, "talker");
ros::NodeHandle n;
ros::Publisher chatter_pub = n.advertise<sensor_msgs::PointCloud2>("chatter", 1000);
    ros::Rate loop_rate(10); 
int speed = 100;

    while (ros::ok()){

    msg.height = speed;
            chatter_pub.publish(msg);
            loop_rate.sleep();
    }

return 0;

}

Approximate time synchronizer, callback is not called

Hi,

My approximate time synchronizer with two topics (Camera and Liar) works fine. But When I add one more topic to it, my callback function seems never get called..

I am attaching the codes below for help. First node is the time synchronizer and second node is additional topic that I want to synchronize with other two topics (camera and lidar).

Thank you in advance.

ros::Publisher image1_pub;
ros::Publisher image2_pub;
ros::Publisher image3_pub;

image3_pub; void callback(const sensor_msgs::Image::ConstPtr& image1, const sensor_msgs::PointCloud2::ConstPtr& image2, const sensor_msgs::PointCloud2::ConstPtr& image3) {

ROS_INFO("Sync_Callback");

image1_pub.publish(image1);

image2_pub.publish(image2);

image3_pub.publish(image3);

}

{ ROS_INFO("Sync_Callback"); image1_pub.publish(image1); image2_pub.publish(image2); image3_pub.publish(image3); } int main(int argc, char** argv) {

{ ros::init(argc, argv, "TimeSynchronizer");

"TimeSynchronizer"); std::string zed1_img_topic = "/zed/right/image_rect_color";

"/zed/right/image_rect_color"; std::string zed2_img_topic = "/velodyne_points";

"/velodyne_points"; std::string zed3_img_topic = "/chatter";

"/chatter"; ros::NodeHandle nh;

message_filters::Subscriber<sensor_msgs::image> nh; message_filters::Subscriber<sensor_msgs::Image> image1_sub(nh, zed1_img_topic, 1);

message_filters::Subscriber<sensor_msgs::pointcloud2> 1); message_filters::Subscriber<sensor_msgs::PointCloud2> image2_sub(nh, zed2_img_topic, 1);

message_filters::Subscriber<sensor_msgs::pointcloud2> 1); message_filters::Subscriber<sensor_msgs::PointCloud2> image3_sub(nh, zed3_img_topic, 1);

1); image1_pub = nh.advertise<sensor_msgs::image>("/synchronized" nh.advertise<sensor_msgs::Image>("/synchronized" + zed1_img_topic, 1000);

1000); image2_pub = nh.advertise<sensor_msgs::pointcloud2>("/synchronized" nh.advertise<sensor_msgs::PointCloud2>("/synchronized" + zed2_img_topic, 1000);

1000); image3_pub = nh.advertise<sensor_msgs::pointcloud2>("/synchronized" nh.advertise<sensor_msgs::PointCloud2>("/synchronized" + zed3_img_topic, 1000);

1000); typedef sync_policies::ApproximateTime<image, pointcloud2,="" pointcloud2=""> MySyncPolicy;

Synchronizer<mysyncpolicy> sync_policies::ApproximateTime<Image, PointCloud2, PointCloud2> MySyncPolicy; Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), image1_sub, image2_sub, image3_sub);

image3_sub); sync.registerCallback(boost::bind(&callback, _1, _2, _3));

ros::spin();

_3)); ros::spin(); return 0;

}

0; } int main (int argc, char **argv){

**argv){

    ros::init(argc, argv, "talker");
 ros::NodeHandle n;
 ros::Publisher chatter_pub = n.advertise<sensor_msgs::PointCloud2>("chatter", 1000);
     ros::Rate loop_rate(10); 
 int speed = 100;

     while (ros::ok()){

     msg.height = speed;
             chatter_pub.publish(msg);
             loop_rate.sleep();
     }

 return 0;
}

}

Approximate time synchronizer, callback is not called

Hi,

My approximate time synchronizer with two topics (Camera and Liar) works fine. But When I add one more topic to it, my callback function seems never get called..

I am attaching the codes below for help. First node is the time synchronizer and second node is additional topic that I want to synchronize with other two topics (camera and lidar).

Thank you in advance.

ros::Publisher image1_pub;
ros::Publisher image2_pub;
ros::Publisher image3_pub;

void callback(const sensor_msgs::Image::ConstPtr& image1, const sensor_msgs::PointCloud2::ConstPtr& image2, const sensor_msgs::PointCloud2::ConstPtr& image3)
{

ROS_INFO("Sync_Callback");

  image1_pub.publish(image1);

  image2_pub.publish(image2);

  image3_pub.publish(image3);

}

int main(int argc, char** argv)
{

 ros::init(argc, argv, "TimeSynchronizer");

  std::string zed1_img_topic = "/zed/right/image_rect_color";

  std::string zed2_img_topic = "/velodyne_points";

  std::string zed3_img_topic = "/chatter";

  ros::NodeHandle nh;

  message_filters::Subscriber<sensor_msgs::Image> image1_sub(nh, zed1_img_topic, 1);

  message_filters::Subscriber<sensor_msgs::PointCloud2> image2_sub(nh, zed2_img_topic, 1);

  message_filters::Subscriber<sensor_msgs::PointCloud2> image3_sub(nh, zed3_img_topic, 1);

  image1_pub = nh.advertise<sensor_msgs::Image>("/synchronized" + zed1_img_topic, 1000);

  image2_pub = nh.advertise<sensor_msgs::PointCloud2>("/synchronized" + zed2_img_topic, 1000);

  image3_pub = nh.advertise<sensor_msgs::PointCloud2>("/synchronized" + zed3_img_topic, 1000);

  typedef sync_policies::ApproximateTime<Image, PointCloud2, PointCloud2> MySyncPolicy;

  Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), image1_sub, image2_sub, image3_sub);

  sync.registerCallback(boost::bind(&callback, _1, _2, _3));

  ros::spin();

  return 0;

}

 int main (int argc, char **argv){

    ros::init(argc, argv, "talker");
    ros::NodeHandle n;
    ros::Publisher chatter_pub = n.advertise<sensor_msgs::PointCloud2>("chatter", 1000);
        ros::Rate loop_rate(10); 
    int speed = 100;

        while (ros::ok()){

        msg.height = speed;
                chatter_pub.publish(msg);
                loop_rate.sleep();
        }

    return 0;
}

Approximate time synchronizer, callback is not called

Hi,

My approximate time synchronizer with two topics (Camera and Liar) works fine. But When I add one more topic to it, my callback function seems never get called..

I am attaching the codes below for help. First node is the time synchronizer and second node is additional topic that I want to synchronize with other two topics (camera and lidar).

Thank you in advance.

ros::Publisher image1_pub;
ros::Publisher image2_pub;
ros::Publisher image3_pub;

void callback(const sensor_msgs::Image::ConstPtr& image1, const sensor_msgs::PointCloud2::ConstPtr& image2, const sensor_msgs::PointCloud2::ConstPtr& image3)
{

ROS_INFO("Sync_Callback");

  image1_pub.publish(image1);

  image2_pub.publish(image2);

  image3_pub.publish(image3);

}

int main(int argc, char** argv)
{

 ros::init(argc, argv, "TimeSynchronizer");

  std::string zed1_img_topic = "/zed/right/image_rect_color";

  std::string zed2_img_topic = "/velodyne_points";

  std::string zed3_img_topic = "/chatter";

  ros::NodeHandle nh;

  message_filters::Subscriber<sensor_msgs::Image> image1_sub(nh, zed1_img_topic, 1);

  message_filters::Subscriber<sensor_msgs::PointCloud2> image2_sub(nh, zed2_img_topic, 1);

  message_filters::Subscriber<sensor_msgs::PointCloud2> image3_sub(nh, zed3_img_topic, 1);

  image1_pub = nh.advertise<sensor_msgs::Image>("/synchronized" + zed1_img_topic, 1000);

  image2_pub = nh.advertise<sensor_msgs::PointCloud2>("/synchronized" + zed2_img_topic, 1000);

  image3_pub = nh.advertise<sensor_msgs::PointCloud2>("/synchronized" + zed3_img_topic, 1000);

  typedef sync_policies::ApproximateTime<Image, PointCloud2, PointCloud2> MySyncPolicy;

  Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), image1_sub, image2_sub, image3_sub);

  sync.registerCallback(boost::bind(&callback, _1, _2, _3));

  ros::spin();

  return 0;

}
 

Second node

int main (int argc, char **argv){

    ros::init(argc, argv, "talker");
    ros::NodeHandle n;
    ros::Publisher chatter_pub = n.advertise<sensor_msgs::PointCloud2>("chatter", 1000);
        ros::Rate loop_rate(10); 
    int speed = 100;

        while (ros::ok()){

        msg.height = speed;
                chatter_pub.publish(msg);
                loop_rate.sleep();
        }

    return 0;
}

Approximate time synchronizer, callback is not called

Hi,

My approximate time synchronizer with two topics (Camera and Liar) works fine. But When I add one more topic to it, my callback function seems never get called..

I am attaching the codes below for help. First node is the time synchronizer and second node is additional topic that I want to synchronize with other two topics (camera and lidar).

Thank you in advance.

ros::Publisher image1_pub;
ros::Publisher image2_pub;
ros::Publisher image3_pub;

void callback(const sensor_msgs::Image::ConstPtr& image1, const sensor_msgs::PointCloud2::ConstPtr& image2, const sensor_msgs::PointCloud2::ConstPtr& image3)
{

ROS_INFO("Sync_Callback");

  image1_pub.publish(image1);

  image2_pub.publish(image2);

  image3_pub.publish(image3);

}

int main(int argc, char** argv)
{

 ros::init(argc, argv, "TimeSynchronizer");

  std::string zed1_img_topic = "/zed/right/image_rect_color";

  std::string zed2_img_topic = "/velodyne_points";

  std::string zed3_img_topic = "/chatter";

  ros::NodeHandle nh;

  message_filters::Subscriber<sensor_msgs::Image> image1_sub(nh, zed1_img_topic, 1);

  message_filters::Subscriber<sensor_msgs::PointCloud2> image2_sub(nh, zed2_img_topic, 1);

  message_filters::Subscriber<sensor_msgs::PointCloud2> image3_sub(nh, zed3_img_topic, 1);

  image1_pub = nh.advertise<sensor_msgs::Image>("/synchronized" + zed1_img_topic, 1000);

  image2_pub = nh.advertise<sensor_msgs::PointCloud2>("/synchronized" + zed2_img_topic, 1000);

  image3_pub = nh.advertise<sensor_msgs::PointCloud2>("/synchronized" + zed3_img_topic, 1000);

  typedef sync_policies::ApproximateTime<Image, PointCloud2, PointCloud2> MySyncPolicy;

  Synchronizer<MySyncPolicy> sync(MySyncPolicy(10), image1_sub, image2_sub, image3_sub);

  sync.registerCallback(boost::bind(&callback, _1, _2, _3));

  ros::spin();

  return 0;

}

Second node

include "ros/ros.h"

include "std_msgs/String.h"

include <sstream>

include <sensor_msgs image.h="">

include <sensor_msgs pointcloud2.h="">

int main (int argc, char **argv){ **argv){

ros::init(argc, argv, "talker");
  ros::NodeHandle n;
  ros::Publisher chatter_pub = n.advertise<sensor_msgs::PointCloud2>("chatter", 1000);
      ros::Rate loop_rate(10); 
  int speed = 100;

     while (ros::ok()){

            sensor_msgs::PointCloud2 msg;

    msg.height = speed;
              chatter_pub.publish(msg);
              loop_rate.sleep();
      }

 return 0;
}

}