custom message fails to build; no such file or directory
I followed the custom message documentation to the letter, and searched all the related questions on here, and unfortunately I am still stuck. Could you please have a look?
I am getting the same error building in Ubuntu 14.04 and 16.04, both running Kinetic.
All my packages that have custom messages fail to build (catkin_make
exits with error). The custom message definition are part of the package, and are not from another package. The error reason is the same for all the packages with custom messages (from my limited understanding the .msg file is not found for some reason): fatal error: ... : No such file or directory ... >
The package organization follows the documentation:
where the custom message file is called my_msg.msg and is inside the msg directory. The contents of my_msg.msg
are not suspect either:
int32 my_int
float64 my_float
The package.xml does contain the needed lines:
<build_depend>message_generation</build_depend>
<run_depend>message_runtime</run_depend>
The CMakeLists.txt contains everything the documentation mentions, and I even ran catkin_create_pkg test
to make sure all the items are arranged in the correct order. Here is the file:
cmake_minimum_required(VERSION 2.8.3)
project(g_custom_messages)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
message_generation
)
add_message_files(
FILES
my_msg.msg
)
generate_messages(DEPENDENCIES std_msgs )
catkin_package(CATKIN_DEPENDS message_runtime)
include_directories(include ${catkin_INCLUDE_DIRS})
add_executable(custom_msg_subscriber src/custom_msg_subscriber.cpp)
target_link_libraries(custom_msg_subscriber ${catkin_LIBRARIES})
and in the source code (file name is custom_msg_subscriber.cpp
and it is inside the src directory), I am refrencing the custom message as #include <g_custom_messages/my_msg.h>
, and am accessing the data via:
void poseMessageReceived(const g_custom_messages::my_msg &msg)
{
storeInt = msg.my_int;
storeFloat = msg.my_float;
}
All the web search gymnastics I did have not helped. Could you please let me know why am I getting an error?
Please check the catkin documentation on how to do this.
I'm fairly certain you're missing the
add_dependencies(..)
bit to let CMake know thatcustom_msg_subscriber
depends on the msgs having been generated.Additionally: for the future: please don't post screenshots of terminals. It's all text, so you can just copy-paste it into your question.
And for reference: updating the
CMakeLists.txt
of nodes using your custom message is explained in the next tutorial.@gvdhoorn Thank you very much for helping. I am learning ROS on my own and I really appreciate your help. Thank you!
No problem. Good to hear you got things to work.