Ros do not appear to be synchronized. In the last 10s: depthimage_to_laserscan 出现同步异常问题的解决方法

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)

激光完美显示。
在这里插入图片描述

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值