Image transport get long delay
I'm using ROS kinetic (Ubuntu 16.04) as following link : http://wiki.ros.org/kinetic/Installat... , installed ROS-Base: (Bare Bones) and image-transport package seperately.
I'm trying to publish raw image (1280 * 720 * 2 bytes) to the other node by using image_transport with roscpp and subscriber need to wait about 10 - 15ms to receive image from publisher.
Publisher:
image_transport::ImageTransport it(nh_);
pub = it.advertise("image_raw", 1);
sensor_msgs::Image msg;
msg.header.seq = count;
msg.header.frame_id = "camera";
msg.header.stamp.sec = ros::Time::now().sec;
msg.header.stamp.nsec = ros::Time::now().nsec;
msg.height = 720;
msg.width = 1280;
msg.data.resize(1280*720*2);
memcpy(msg.data.data(), image_ptr_0, 1280*720*2);
pub.publish(msg);
Subscriber
image_transport::ImageTransport it(nh_);
image_transport::Subscriber sub = it.subscribe("/camera_pkg_node/image_raw", 1, ImageCallback);
void ImageCallback (const sensor_msgs::ImageConstPtr& msg)
{
printf ("Receive Image Start Time at %ds:%dms \r\n", msg->header.stamp.sec, msg->header.stamp.nsec/1000000);
printf ("Receive Image Recv Time at %ds:%dms \r\n", ros::Time::now().sec, ros::Time::now().nsec/1000000);
}
Console
Receive Image Start Time at 1530091465s:977ms
Receive Image Recv Time at 1530091465s:989ms
Receive Image Start Time at 1530091466s:7ms
Receive Image Recv Time at 1530091466s:18ms
Is there any way to reduce latency between publisher and subscriber.
Thanks and Best Regards, Vu Nguyen
Edit (made by @William):
Hi VictorLamoine,
Thank for you reply. Actually I want to measure the delay of Publishing/Subscribing. I tried to measure time for resizing and copying image as well as Publishing/Subscribing, this is the result
Time stamp before resizing and copying : 1530144835s:805ms
Time stamp after resizing and copying : 1530144835s:806ms
Time stamp after receive at Subscriber : 1530144835s:817ms
As we can see, resizing and copy take only 1ms but Publishing/Subscribing need more than 10ms. I'm wondering there is any way to reduce this latency.
Updated:
Even though I tried with small data (about 10 -20 bytes) with normal publish/subscribe it took 1-2 ms, I think it was acceptable but sometime it took 5-6ms or 7-8ms.
Thanks and Best Regards,
Which version of ROS 2 are you using, what OS are you on, and how did you install it?
Please add that information to your original question, thanks!
Hi William,
I'm using ROS kinetic (Ubuntu 16.04) as following link : http://wiki.ros.org/kinetic/Installat... I installed ROS-Base: (Bare Bones) and image-transport package seperately.
Thanks and Best Regards,
Ok, so ROS Kinetic is ROS 1, so I retagged your question.