无法创建自定义消息 [英] Cannot create custom message

查看:92
本文介绍了无法创建自定义消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我目前正在尝试为现有包创建自定义消息,但是我创建了 Point_id.msg,但是当我将其作为头文件包含在代码中时,我收到以下错误

Hi i am currently trying to create a custom message for an exisitng package however i create Point_id.msg but when i included it as a header file in my code, i receive the following error

/home/111/222/333/find_object_2d/src/objects_detected.cpp:7:41: fatal error:       
find_object_2d/PointObjects.h: No such file or directory
compilation terminated.
make[2]: *** [find_object_2d/CMakeFiles/objects_detected.dir/src/objects_detected.cpp.o] Error 1
make[1]: *** [find_object_2d/CMakeFiles/objects_detected.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed

这是我在 Point_id.msg 中包含的内容:

This is what i included in Point_id.msg :

int16 id
geometry_msgs/Point punto

这是我在代码中的头文件:

This is my include header in the codes:

#include <find_object_2d/PointObjects.h>
#include <find_object_2d/Point_id.h

在现有的 cmakelist.txt 中没有 # rosbuild_gensrv() 的迹象那么我应该在现有包中创建一个新包并在 src 文件夹中创建 .msg 文件并尝试构建它吗?或者我该怎么办?我真的很困惑.

In the existing cmakelist.txt there was no sign of # rosbuild_gensrv() so should i create a new package within the existing package and create the .msg files in the src folder and try to build it? or what should i do? i'm really confused.

请帮忙谢谢!

推荐答案

你必须稍微修改一下包的 CMakeLists.txt ,否则 *.h 文件将不会生成.

You have to modify the CMakeLists.txt of the package a bit, otherwise the *.h files will not be generated.

如果您使用 rosmake:

只需将 rosbuild_genmsg() 添加到 CMakeLists.txt

Simply add rosbuild_genmsg() to CMakeLists.txt

如果您使用柳絮:

使用柳絮就有点复杂了:

With catkin it is a bit more complicated:

将message_generation"添加到find_package(catkin REQUIRED COMPONENTS ...

Add "message_generation" to find_package(catkin REQUIRED COMPONENTS ... and

add_message_files(
  FILES
  Point_id.msg
)
generate_messages(
  DEPENDENCIES
  geometry_msgs
)

我希望,这会有所帮助.

I hope, this helps.

这篇关于无法创建自定义消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆