How to use message from another package
So I am trying to use a custom msg (Drive.msg) that I created in the boat_controller project inside the same workspace. This message is necessary for connecting boat_hw with boat_controller.
Github: in the same workspace I have the following projects:
boat_hw : https://github.com/renanmb/boat_hw
boat_controller : https://github.com/renanmb/boat_pid_c...
VESC : https://github.com/renanmb/VESC
So how do I do it on the CMakefile.txt , It really got me confused. Message is in boat_controller and I wanna build it in boat_hw.
This is the error shown by the Terminal:
[ 96%] Building CXX object boat_hw/CMakeFiles/robot.dir/src/boat_hw.cpp.o
[ 96%] Building CXX object boat_hw/CMakeFiles/robot.dir/src/robot.cpp.o
In file included from /home/renan/rostest_ws/src/boat_hw/src/boat_hw.cpp:1:0:
/home/renan/rostest_ws/src/boat_hw/src/boat_hw.h:5:37: fatal error: boat_controller/Drive.msg: No such file or directory
compilation terminated.
boat_hw/CMakeFiles/robot.dir/build.make:86: recipe for target 'boat_hw/CMakeFiles/robot.dir/src/boat_hw.cpp.o' failed
make[2]: *** [boat_hw/CMakeFiles/robot.dir/src/boat_hw.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /home/renan/rostest_ws/src/boat_hw/src/robot.cpp:1:0:
/home/renan/rostest_ws/src/boat_hw/src/boat_hw.h:5:37: fatal error: boat_controller/Drive.msg: No such file or directory
compilation terminated.
boat_hw/CMakeFiles/robot.dir/build.make:62: recipe for target 'boat_hw/CMakeFiles/robot.dir/src/robot.cpp.o' failed
make[2]: *** [boat_hw/CMakeFiles/robot.dir/src/robot.cpp.o] Error 1
CMakeFiles/Makefile2:4519: recipe for target 'boat_hw/CMakeFiles/robot.dir/all' failed
make[1]: *** [boat_hw/CMakeFiles/robot.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j6 -l6" failed
This is my CMakelist.txt
cmake_minimum_required(VERSION 2.8.3)
project(boat_hw)
find_package(catkin REQUIRED COMPONENTS vesc_driver vesc_msgs controller_manager)
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
CATKIN_DEPENDS vesc_driver vesc_msgs boat_controller
)
include_directories(
include
${Boost_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
)
add_executable(robot
src/robot.cpp
src/boat_hw.cpp
src/boat_driver.cpp
)
add_dependencies(robot ${catkin_EXPORTED_TARGETS})
target_link_libraries(robot
${catkin_LIBRARIES}
vesc_driver_nodelet
${boat_controller}
# add_library(${PROJECT_NAME}
src/${boat_controller}/Drive.msg
#controller_manager
)
Please remove all the comments from your
CMakeLists.txt
. They are not needed and make your post unnecessarily long.I've changed the title of your question, as you are explicitly asking how to use messages from other packages and make compilation work.
and I am pretty confused, I know I could just create a message folder. I want to use messages from other packages without the need of creating the folder again. I saw in some other projects people creating a package just with messages.