Ros publish() taking more time than expected
Dear All
I have observed a strange behavior in my node.
I am trying to publish pointcloud topic and subscribing in another node.
While profiling the pointcloud node I have observed the publish() method was taking around 10ms of the time.
When no one subscribing there is no delay. The delay was observed when the other node was subscribing to the topic.
I have also tried to echo the topic and observe the time.I have observed around 2ms delay.
Can any one explain me why this was happening and how can I minimize this overhead ?
EDIT: Adding source code
The snippet of code in the main method of the pointcloud subscribing node. In side callback I have only a print statement.
`typedef sync_policies::ExactTime<sensor_msgs::PointCloud2 ,sensor_msgs::Image, sensor_msgs::CameraInfo> MySyncPolicy;
message_filters::Subscriber<sensor_msgs::CameraInfo> imageCam_sub(nh,left_info_topic, 50);
message_filters::Subscriber<sensor_msgs::Image> image_sub(nh, left_topic, 50);
message_filters::Subscriber<sensor_msgs::PointCloud2> PC_sub(nh, topic_name, 50);
Synchronizer<MySyncPolicy> sync(MySyncPolicy(50),PC_sub, image_sub, imageCam_sub);
sync.registerCallback(boost::bind(&callback, &oD, _1, _2,_3));`
Thanks in advance
You can try nodelets. It is faster specially in case of pointclouds.
I have tried them already and didn't observed much time difference.