Cannot create custom message

孤街浪徒 提交于 2019-12-11 17:39:59

问题


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

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

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.

Please help thank you!


回答1:


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

If you use rosmake:

Simply add rosbuild_genmsg() to CMakeLists.txt

If you use catkin:

With catkin it is a bit more complicated:

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.



来源:https://stackoverflow.com/questions/27889141/cannot-create-custom-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!