Ros do not appear to be synchronized. In the last 10s: depthimage_to_laserscan 出现同步异常问题的解决方法
[image_transport] Topics ‘/camera/depth/camera_raw’ and ‘/camera/depth/camera_info’ do not appear to be synchronized. In the last 10s:
最近在做ROS相关的研究,遇到一个很诡异的问题
[ WARN] [1627472909.602867472]: [image_transport] Topics '/camera/depth/objectfiltercamera' and '/camera/depth/camera_info' do not appear to be synchronized. In the last 10s:
Image messages received: 250
CameraInfo messages received: 297
Synchronized pairs: 0
[ WARN] [1627472919.602789735]: [image_transport] Topics '/camera/depth/objectfiltercamera' and '/camera/depth/camera_info' do not appear to be synchronized. In the last 10s:
Image messages received: 250
CameraInfo messages received: 297
Synchronized pairs: 93
[ WARN] [1627473169.602954802]: [image_transport] Topics '/camera/depth/objectfiltercamera' and '/camera/depth/camera_info' do not appear to be synchronized. In the last 10s:
Image messages received: 250
CameraInfo messages received: 297
Synchronized pairs: 83
[ WARN] [1627473179.602794876]: [image_transport] Topics '/camera/depth/objectfiltercamera' and '/camera/depth/camera_info' do not appear to be synchronized. In the last 10s:
Image messages received: 250
CameraInfo messages received: 297
Synchronized pairs: 84
我的情况是自己写了一个深度图的处理,然后通过发布出去,但是一旦我触发我自己设置的返回的深度图就会卡住,然后就一直显示depthimage_to_laserscan 包中一直报错,甚至还打算产品重写一些包中的同步相关的内容。但是,我在分析rostopic 返回的数据时发现了问题,然后怀疑是否是header的问题,没想到确实是。
左边是我自己写的,右边是订阅的深度图,其他数据基本一样,除了header的stamp和seq参数,于是我在代码将自己发布的深度图的header替换成原先订阅数据的header。
def publish_depth_results(self,image,data):
if(len(data) == 0):
self.depth_pub.publish(image)
return
cv_image = self.bridge.imgmsg_to_cv2(image, "32FC1")
cv_image = cv_image.reshape(480,640)
#(x1 y1 x2 y2)
for i in range(int(len(data)/4)):
# y1 y2 x1 x2
y1 = int(data[i*4+1])
y2 = int(data[i*4+3])
x1 = int(data[i*4])
x2 = int(data[i*4+2])
# cv_image[y1:y2,x1:x2]= nan
# 去除方框上部内容
cv_image[:y1,:] = nan
# 去除方框下部内容
cv_image[y2:,:] = nan
# 去除方框左部内容
cv_image[:,:x1] = nan
# 去除方框右部publish回去,否则无法识别。直接原始分辨率即可。
# cv_image = cv_image.reshape(480*640)
publish_image = self.bridge.cv2_to_imgmsg(cv_image,"32FC1")
publish_image.header = image.header
self.depth_pub.publish(publish_image) def publish_depth_results(self,image,data):
if(len(data) == 0):
self.depth_pub.publish(image)
return
cv_image = self.bridge.imgmsg_to_cv2(image, "32FC1")
cv_image = cv_image.reshape(480,640)
#(x1 y1 x2 y2)
for i in range(int(len(data)/4)):
# y1 y2 x1 x2
y1 = int(data[i*4+1])
y2 = int(data[i*4+3])
x1 = int(data[i*4])
x2 = int(data[i*4+2])
# cv_image[y1:y2,x1:x2]= nan
# 去除方框上部内容
cv_image[:y1,:] = nan
# 去除方框下部内容
cv_image[y2:,:] = nan
# 去除方框左部内容
cv_image[:,:x1] = nan
# 去除方框右部publish回去,否则无法识别。直接原始分辨率即可。
# cv_image = cv_image.reshape(480*640)
publish_image = self.bridge.cv2_to_imgmsg(cv_image,"32FC1")
# 替换为原始image的header,否则会出现无法同步的的问题。
publish_image.header = image.header
self.depth_pub.publish(publish_image)
激光完美显示。