【ros2订阅报错】 ros2 forming pointer to reference type ‘const std::shared_ptr<const sensor_msgs::msg::Las

2023-05-16

这里写自定义目录标题

  • 使用ROS2创建发布者

使用ROS2创建发布者

在创建发布者的时候,出现,如下问题,经过修改cmakeList发现并不是cmake版本问题。
···
/usr/include/c++/9/bits/alloc_traits.h:399:13: error: forming pointer to reference type ‘const std::shared_ptr<const sensor_msgs::msg::LaserScan_<std::allocator > >&’
399 | using pointer = Tp*;
| ^~~~~~~
/usr/include/c++/9/bits/alloc_traits.h:402:13: error: forming pointer to reference type ‘const std::shared_ptr<const sensor_msgs::msg::LaserScan
<std::allocator > >&’
402 | using const_pointer = const Tp*;
| ^~~~~~~~~~~~~
In file included from /usr/include/c++/9/memory:80,
from /home/robot/localization_and_mapping/src/cartographer_ros/cartographer_ros/./cartographer_ros/relocation_node_main.h:21,
from /home/robot/localization_and_mapping/src/cartographer_ros/cartographer_ros/cartographer_ros/relocation_node_main.cc:17:
/usr/include/c++/9/bits/unique_ptr.h: In instantiation of ‘struct std::default_delete<const std::shared_ptr<const sensor_msgs::msg::LaserScan
<std::allocator > >&>’:
/opt/ros/foxy/include/rclcpp/message_memory_strategy.hpp:119:18: required from ‘class rclcpp::message_memory_strategy::MessageMemoryStrategy<const std::shared_ptr<const sensor_msgs::msg::LaserScan_<std::allocator > >&, std::allocator >’
/opt/ros/foxy/include/rclcpp/node_impl.hpp:91:1: required by substitution of ‘template<class MessageT, class CallbackT, class AllocatorT, class CallbackMessageT, class SubscriptionT, class MessageMemoryStrategyT> std::shared_ptr rclcpp::Node::create_subscription(const string&, const rclcpp::QoS&, CallbackT&&, const rclcpp::SubscriptionOptionsWithAllocator&, typename MessageMemoryStrategyT::SharedPtr) [with MessageT = sensor_msgs::msg::LaserScan_<std::allocator >; CallbackT = std::Bind<void (cartographer_ros::RelocationActionServer::(cartographer_ros::RelocationActionServer, std::Placeholder<1>))(const std::shared_ptr<const sensor_msgs::msg::LaserScan<std::allocator > >&)>; AllocatorT = std::allocator; CallbackMessageT = const std::shared_ptr<const sensor_msgs::msg::LaserScan<std::allocator > >&; SubscriptionT = rclcpp::Subscription<const std::shared_ptr<const sensor_msgs::msg::LaserScan_<std::allocator > >&, std::allocator, rclcpp::message_memory_strategy::MessageMemoryStrategy<const std::shared_ptr<const sensor_msgs::msg::LaserScan_<std::allocator > >&, std::allocator > >; MessageMemoryStrategyT = rclcpp::message_memory_strategy::MessageMemoryStrategy<const std::shared_ptr<const sensor_msgs::msg::LaserScan_<std::allocator > >&, std::allocator >]’
/home/robot/localization_and_mapping/src/cartographer_ros/cartographer_ros/./cartographer_ros/relocation_node_main.h:122:162: required from here
/usr/include/c++/9/bits/unique_ptr.h:71:9: error: forming pointer to reference type ‘const std::shared_ptr<const sensor_msgs::msg::LaserScan_<std::allocator > >&’
71 | default_delete(const default_delete<Up>&) noexcept { }
| ^~~~~~~~~~~~~~
/usr/include/c++/9/bits/unique_ptr.h:75:7: error: forming pointer to reference type ‘const std::shared_ptr<const sensor_msgs::msg::LaserScan
<std::allocator > >&’
75 | operator()(_Tp* __ptr) const
| ^~~~~~~~
···

原因是callback函数中的参数不得是引用的形式。需要去除&。
如下,将内容修改:

void ScanCallback(const sensor_msgs::msg::LaserScan::ConstSharedPtr &scan);

到:

void ScanCallback(const sensor_msgs::msg::LaserScan::ConstSharedPtr scan);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

【ros2订阅报错】 ros2 forming pointer to reference type ‘const std::shared_ptr<const sensor_msgs::msg::Las 的相关文章

随机推荐

  • 经验分享一:UART 可进入空闲中断,DMA却没数据

    条件 xff1a UART DMA配置没有问题 时钟也都使能了 xff0c 对照寄存器表 xff0c 发现该配置的寄存器都配置的没问题 xff0c 调试发现每次接收到数据 xff0c 可以顺利进入空闲中断 且读取 UART 34 数据接收寄
  • Visual Studio 2022 C++ CLR 的艰难除 Bug

    请看下面一段代码 xff1a 运行结果 xff1a 这是一个Button xff0c 要用到这段代码是因为字符串出了问题 xff1a 肯定是我写的类出问题了 xff0c 便是我在控制台下测试是正常的 代码 xff1a 运行结果 xff1a
  • UBX 协议报文整理

    UBX 协议报文整理 UBX 协议的报文格式如下 xff1a 帧头 2 byte CLASS ID MESSAGE ID 2 byte 消息长度 2 byte PAYLOAD校验和 2 byte 帧头 由两个字节组成 xff0c 即0xB5
  • 将串口接收的数据绘制成波形图(使用matlab或Visual Scope)

    一 串口通信配置 结合stm32固件库 xff08 或其它类型单片机 xff09 中usart相关的函数 xff0c 配置好串口通信的寄存器 xff0c 确定 xff08 数据位 停止位 波特率等等 xff09 xff0c 本文主要介绍两种
  • linux下makefile、make、Cmake的区别

    Makefile make工具 linux下makeflie和make的用法 makefile与make详解 人们通常利用make工具来自动完成编译工作 这些工作包括 xff1a 如果仅修改了某几个源文件 xff0c 则只重新编译这几个源文
  • 常见的HTTP请求报文头

    目录 AcceptCookieConnectionCache ControlHostRefererUser Agent 参考链接 HTTP请求行 请求头 请求体详解 关于常用的http请求头以及响应头详解 Accept Accept app
  • C++中::和:的意思

    C 43 43 中的 1 类作用域 指明成员函数所属的类 span class token class name M span span class token operator span span class token function
  • Git 基础知识--打Tag、团队协作

    打 Tag 简述 Git 可以给历史中的某一个提交打上标签 tag xff0c 以示重要 人们一般用 tag 功能来标记发布节点 xff08 v1 0 xff09 tag 与 分支很像 xff0c 区别在于 xff1a 轻量标签 tag 是
  • 第七章——VINS系统初始化

    前言 这一章主要内容是讲的VINS系统初始化的事 xff0c 内容上还是比较全面丰满的 xff0c 有一些有疑问的点我之后读了代码会在博客里补上 一句话总结初始化 xff1a 以优化量与观测值构建残差 xff0c 提取优化量构成最小二乘问题
  • GIT系列之标签

    1 标签列表 git tag 在控制台打印出当前仓库的所有标签 git tag l 39 v1 39 搜索符合模式的标签 2 打标签 git标签分为两种类型 xff1a 轻量标签和附注标签 轻量标签是指向提交对象的引用 附注标签则是仓库中的
  • printf重定向(重新定义发送数据的方向)

    1 串口使用 printf 需要对 printf 重定向 也就是需要重定义 fputc xff08 xff09 这个函数 xff08 这个函数是printf的底层函数 xff09 转 int fputc span class token p
  • 解决nvcc找不到的问题/bin/sh:1:nvcc:not found

    这里写自定义目录标题 问题描述方法探索解决方法 问题描述 在执行make指令进行编译的时候 xff0c 遇到问题 34 bin sh 1 nvcc not found 34 xff0c 如图所示 其原因是未找到nvcc xff0c 于是开始
  • GPS的Heading, Course, and Crab Angle不同与区别

    看了老外这个文章终于知道GPS的Heading Course and Crab Angle不同与区别 xff0c 好东西分享给大家 http www chrobotics com library heading course and cra
  • 交换机对数据帧的转发和过滤

    大家好呀 xff0c 我是请假君 xff0c 今天又来和大家一起学习数通了 xff0c 今天要分享的知识是交换机对数据帧的转发和过滤 一 单播帧的转发 xff1a 交换机根据MAC地址表项进行数据帧转发 上图中 xff0c PCA发出数据帧
  • python3运行ros方法 No module named 'rospkg'

    我们安装的ros后 其一般的库文件均基于python2 但是当某个项目必须要用python3时 就会出现如下错误 Traceback most recent call last File 34 home jetbot arm all xAr
  • 二维码识别与定位-方法1-利用ar_track_alvar

    二维码识别作为一种快捷准确的技术已经应用与生活中的购物支付 物体识别及工业AGV导航等领域 xff0c 在OpenCV3 4 4版本上均提供了相应的函数cv QRCodeDetector detectAndDecode 用于二维码的检测和解
  • Jetson xavier NX进行apt update及安装ROS出错记录

    Jetson xavier NX ROS 在Jetson xaiver NX上准备安装ROS xff0c 在执行apt get update时出现如 34 Failed to fetch https mirrors aliyun com u
  • Ubuntu18.04安装ROS2并使用ROS1的bag和cartographer来建图

    目录 概述1 安装ROS21 xff09 安装python3及colcon2 xff09 添加ROS2的源3 xff09 安装eloquent桌面版本4 xff09 修改 bashrc 2 安装cartographer及cartograph
  • Linux获取指定进程CPU和内存占用率

    Linux获取指定进程CPU和内存占用率 创建如下python程序 caclute memory occupied py import psutil import pynvml import time class MonitorProces
  • 【ros2订阅报错】 ros2 forming pointer to reference type ‘const std::shared_ptr<const sensor_msgs::msg::Las

    这里写自定义目录标题 使用ROS2创建发布者 使用ROS2创建发布者 在创建发布者的时候 xff0c 出现 xff0c 如下问题 xff0c 经过修改cmakeList发现并不是cmake版本问题 usr include c 43 43 9