message_filter::sync_policies::ApproximateTime注册回调函数中的报错问题

1 篇文章 0 订阅

官方文档给出的教程如下:

Input

C++: Up to 9 separate filters, each of which is of the form
void callback(const boost::shared_ptr&).
The number of filters supported is determined by the number of template arguments the class was created with. Python: N separate filters, each of which has signature callback(msg).

Output

C++: For message types M0…M8,
void callback(const boost::shared_ptr&, …, const boost::shared_ptr&).
The number of parameters is determined by the number of template arguments the class was created with. Python: callback(msg0… msgN). The number of parameters is determined by the number of template arguments the class was created with.

但按照该教程编写回调函数,编译时一直报错,而且错误又臭又长,找不出问题所在。
在这里插入图片描述

起初以为是语法问题,改了多种方式和顺序,到注册回调函数的时候依然报错,报错片段如下
在这里插入图片描述
在这里插入图片描述

研读了一番示例代码后,发现使用的消息类型为sensor_msgs::Image,回调函数中参数类型为const sensor_msgs::ImageConstPtr &
进而去查了该类型的文档,发现对比如下
Image与ImageConstPtr对比sensor_msgs是一个命名空间,而Image是该命名空间中的一个类。前面的::表示全局
在这里插入图片描述
于是在回调函数参数前加了::顺利解决问题
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

NobleFlower

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值