当前位置:网站首页>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::
边栏推荐
- vscode编写markdown文件并生成pdf
- Introduction to common components of IOT low code platform
- dolphinscheduler2. Installation of X (valid for personal test)
- Youju new material rushes to Shenzhen Stock Exchange: it plans to raise 650million yuan, with an annual revenue of 333million yuan
- 论文解读(GCC)《Efficient Graph Convolution for Joint Node RepresentationLearning and Clustering》
- code snippet
- 证券公司和银行哪个更安全 怎么办理开户最安全
- QQ被盗号后群发黄图,大批用户“社死”
- 完整的模型训练套路(一)
- Leetcode(665)——非递减数列
猜你喜欢

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

Express模板引擎

新零售线下店逆势起飞,通膨乌云下的消费热情

当下不做元宇宙,就像20年前没买房!

Vscode writes markdown file and generates pdf

运行近20年,基于Win 98的火星探测器软件迎来首次升级

New offline retail stores take off against the trend, and consumption enthusiasm under the dark cloud of inflation

The latest pycharm activation cracking code in 2022 is permanent_ Detailed installation tutorial (applicable to multiple versions)

The hidden crisis of Weilai: past, present and future

The boss told me three times: low key, low key, low key
随机推荐
The latest pycharm activation cracking code in 2022 is permanent_ Detailed installation tutorial (applicable to multiple versions)
请问一下,是不是insert all这种oracle的批量新增没拦截?
论文解读(GCC)《Efficient Graph Convolution for Joint Node RepresentationLearning and Clustering》
Maingene listed on the Hong Kong Stock Exchange: IPO with a market value of HK $4.3 billion was ignored by the market
High "green premium" of environmental protection products? How far is the low-carbon lifestyle from people
Angers medical sprint scientific innovation board: annual revenue of RMB 300million and proposed fund raising of RMB 770million
10 key points to effectively improve performance interview
【空间&单细胞组学】第1期:单细胞结合空间转录组研究PDAC肿瘤微环境
运行近20年,基于Win 98的火星探测器软件迎来首次升级
解决Unable to create process using ‘D:\Program File
Calculator (force buckle)
[MySQL learning notes 23] index optimization
成龙和快品牌,谁才是快手的救星?
JS judge whether the string is empty or not
R语言ggplot2可视化:使用patchwork包(直接使用加号+)将一个ggplot2可视化结果和数据表格横向组合起来形成最终结果图
Oracle11g数据库使用expdp每周进行数据备份并上传到备份服务器
Steve Jobs of the United States, died; China jobs, sold
Could you tell me whether the batch addition of Oracle such as insert all was not blocked?
Leetcode (167) -- sum of two numbers II - input ordered array
How to solve the following problems in the Seata database?