当前位置:网站首页>ROS知识点——话题消息的定义与使用
ROS知识点——话题消息的定义与使用
2022-06-28 15:04:00 【Jerry_Sea】
参考:https://www.guyuehome.com/34659
一、先生成person.h头文件(1定义msg文件;2在package.xml中添加功能包依赖;3在CMakeLists.txt添加编译选项;4编译生成语言相关文件)
二、再配置该头文件(1创建publisher和subscriber;2CMakeLists.txt中添加依赖项.)
bug1:package.xml
编译依赖,依赖动态产生message的功能包message_generation
<build_depend>message_generation</build_depend>
<exec_depend>message_runtime</exec_depend>
在package.xml中必须写上上面编译和运行依赖,否则会出现以下报错:
catkin_package() DEPENDS on the catkin package ‘message_runtime’ which must therefore be listed as a run dependency in the package.xml
bug2:CMakeLists.txt
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
message_generation
)
添加编译依赖功能包message_generation
add_message_files(FILES Person.msg)
generate_messages(DEPENDENCIES std_msgs)
上面是把.msg文件编译成不同程序文件的配置项(没有这句,catkin_make时,在devel/include下面就不会生成.h文件,Person.h)
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES learning_msg
CATKIN_DEPENDS roscpp rospy std_msgs message_runtime
# DEPENDS system_lib
)
在catkin_package()里面创建运行依赖
bug3:catkin_make
msg文件首字母要大写,Person.msg
catkin_make后会在该路径下devel/include/功能包生成Person.h
bug4:add_dependencies()
add_dependencies(person_publisher ${PROJECT_NAME}_generate_messages_cpp)
因为有一些代码是动态生成的,所以需要让可执行文件和动态生成的程序产生依赖关系,这一句话是用来跟刚才通过.msg文件生成的头文件(person.h)去做链接的。跟自定义消息做链接必须添加这句话。
bug5:再次catkin_make报错
是由于直接复制的代码中引用的头文件功能包名为learning_topic,所以更改两个cpp内容为下面内容:
#include "learning_msg/Person.h"
并且对应learning_topic::也要改为learning_msg::
边栏推荐
- Q-Tester 3.2:适用于开发、生产和售后的诊断测试软件
- Introduction to common components of IOT low code platform
- WSUS客户端访问服务端异常报错-0x8024401f「建议收藏」
- Ding! Techo day Tencent technology open day arrived as scheduled!
- 组合总和-Leetcode
- 叮!Techo Day 腾讯技术开放日如约而至!
- 【黑马早报】腾讯回应大批用户QQ号被盗;薇娅丈夫公司被罚19万;中国恒大被申请清盘;关晓彤奶茶店回应被加盟商起诉...
- Leetcode(88)——合并两个有序数组
- Leetcode(167)——两数之和 II - 输入有序数组
- vector详解+题目
猜你喜欢

张同学还没学会当主播

Steve Jobs of the United States, died; China jobs, sold

Facebook出手!自适应梯度打败人工调参

老板囑咐了三遍:低調、低調、低調

Q-Tester 3.2:适用于开发、生产和售后的诊断测试软件
一文教你快速生成MySQL数据库关系图

Leetcode 705. Design hash collection

Successful cases of rights protection of open source projects: successful rights protection of SPuG open source operation and maintenance platform

Recommended practice sharing of Zhilian recruitment based on Nebula graph

Classmate Zhang hasn't learned to be an anchor yet
随机推荐
2022年最新PyCharm激活破解码永久_详细安装教程(适用多版本)
【数字IC精品文章收录】近500篇文章|学习路线|基础知识|接口|总线|脚本语言|芯片求职|安全|EDA|工具|低功耗设计|Verilog|低功耗|STA|设计|验证|FPGA|架构|AMBA|书籍|
WSUS客户端访问服务端异常报错-0x8024401f「建议收藏」
Jingyuan's safe sprint to the Growth Enterprise Market: it plans to raise 400million yuan for investment and Yunyou software is the shareholder
Introduction to common components of IOT low code platform
PostgreSQL实现按年、月、日、周、时、分、秒的分组统计
不要使用短路逻辑编写 stl sorter 多条件比较
R语言ggplot2可视化:patchwork包将一个ggplot2可视化结果和一个plot函数可视化结果横向组合起来形成最终结果图、两个可视化的组合结果对齐、并为组合图像的每个子图添加标题
R语言ggplot2可视化:使用patchwork包(直接使用加号+)将一个ggplot2可视化结果和一个plot函数可视化结果横向组合起来形成最终结果图、将两个可视的组合结果对齐
成龙和快品牌,谁才是快手的救星?
买卖股票的最佳时机
The latest pycharm activation cracking code in 2022 is permanent_ Detailed installation tutorial (applicable to multiple versions)
How to solve the following problems in the Seata database?
鸟类飞行状态下穿戴式神经信号与行为数据检测记录系统的技术难点总结
[collection of excellent articles on Digital IC] nearly 500 articles | learning route | basic knowledge | interface | bus | scripting language | chip job search | security | EDA | tools | low power de
The boss told me three times: low key, low key, low key
请问一下,是不是insert all这种oracle的批量新增没拦截?
从莫高窟到太平洋,海量数据找到了新家园
老板囑咐了三遍:低調、低調、低調
The hidden crisis of Weilai: past, present and future