Custom action message can't be found during compilation
So I created a custom action message, under the laser_line_extraction/action folder:
CornerExtractionAction.action:
#goal definition
bool flag
---
#result definition
geometry_msgs/Point[] points
---
#feedback
geometry_msgs/Point[] points
by which I include it in my executables .cpp as such:
#include <laser_line_extraction/CornerExtractionAction.h>
also tried as:
#include "laser_line_extraction/CornerExtractionAction.h"
but when I run catkin build, I get this error message and I couldn't figure out yet what's the problem.
/home/alexnic/conbotics/src/cb_spraybase/cb_perception/laser_line_extraction/src/corner_action_client.cpp:4:10: fatal error: laser_line_extraction/CornerExtractionAction.h: No such file or directory
#include <laser_line_extraction/CornerExtractionAction.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/corner_action_client.dir/src/corner_action_client.cpp.o] Error 1
make[1]: *** [CMakeFiles/corner_action_client.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
/home/alexnic/conbotics/src/cb_spraybase/cb_perception/laser_line_extraction/src/corner_action_server.cpp:10:10: fatal error: laser_line_extraction/CornerExtractionAction.h: No such file or directory
#include <laser_line_extraction/CornerExtractionAction.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/corner_action_server.dir/src/corner_action_server.cpp.o] Error 1
make[1]: *** [CMakeFiles/corner_action_server.dir/all] Error 2
make: *** [all] Error 2
I also tried with deleting devel and build folder but yet the problem exist. I'll also post relevant files for your reference. I would appreciate it if anyone identifies my mistake. Thank you in advance. (Running on ROS1 melodic)
CMakeLists:
cmake_minimum_required(VERSION 2.8.3)
project(laser_line_extraction)
find_package(catkin REQUIRED COMPONENTS
cmake_modules
geometry_msgs
roscpp
rospy
sensor_msgs
visualization_msgs
geometry_msgs
message_generation
actionlib_msgs
actionlib
)
find_package(Eigen3 REQUIRED)
add_message_files(
FILES
LineSegment.msg
LineSegmentList.msg
)
add_service_files(
FILES
CornerExtraction.srv
)
add_action_files(
DIRECTORY action
FILES CornerExtractionAction.action
)
generate_messages(
DEPENDENCIES
sensor_msgs
geometry_msgs
actionlib
actionlib_msgs
)
catkin_package(
INCLUDE_DIRS include
LIBRARIES line line_extraction line_extraction_ros
CATKIN_DEPENDS geometry_msgs message_runtime roscpp sensor_msgs visualization_msgs actionlib_msgs actionlib
)
add_library(line src/line.cpp)
target_link_libraries(line ${catkin_LIBRARIES})
add_library(line_extraction src/line_extraction.cpp)
target_link_libraries(line_extraction ${catkin_LIBRARIES})
add_library(line_extraction_ros src/line_extraction_ros.cpp)
target_link_libraries(line_extraction_ros line line_extraction ${catkin_LIBRARIES})
add_dependencies(line_extraction_ros laser_line_extraction_generate_messages_cpp)
add_executable(line_extraction_node src/line_extraction_node.cpp)
target_link_libraries(line_extraction_node line_extraction_ros ${catkin_LIBRARIES})
add_executable(corner_extraction src/corner_extraction.cpp)
target_link_libraries(corner_extraction line_extraction_ros ${catkin_LIBRARIES})
add_executable(line_server src/line_server.cpp)
target_link_libraries(line_server ${catkin_LIBRARIES})
add_dependencies(line_server laser_line_extraction_gencpp)
add_executable(corner_client src/corner_client.cpp)
target_link_libraries(corner_client ${catkin_LIBRARIES})
add_dependencies(corner_client laser_line_extraction_gencpp)
add_executable(corner_action_server src/corner_action_server.cpp)
target_link_libraries(corner_action_server ${catkin_LIBRARIES})
# add_dependencies(corner_action_server ${laser_line_extraction_EXPORTED_TARGETS})
add_dependencies(corner_action_server laser_line_extraction_generate_messages_cpp)
add_executable(corner_action_client src/corner_action_client.cpp)
target_link_libraries(corner_action_client ${catkin_LIBRARIES})
# add_dependencies(corner_action_client ${laser_line_extraction_EXPORTED_TARGETS})
add_dependencies(corner_action_client laser_line_extraction_generate_messages_cpp)
include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
include_directories(include ${EIGEN3_INCLUDE_DIRS})
# catkin_add_gtest(${PROJECT_NAME}-test test/test_laser_line_extraction.cpp)
install(TARGETS line_extraction_node RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
install(TARGETS line_extraction_ros line_extraction line ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION})
install(DIRECTORY include/${PROJECT_NAME}/ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
I tried also with:
add_dependencies(corner_action_server ${laser_line_extraction_EXPORTED_TARGETS})
add_dependencies(corner_action_client ${laser_line_extraction_EXPORTED_TARGETS})
And package.xml:
<?xml version="1.0"?>
<package>
<name>laser_line_extraction</name>
<version>0.1.0</version>
<description>
A ROS package to extract line segments from LaserScan messages.
</description>
<maintainer email="m.gallant@queensu.ca">Marc Gallant</maintainer>
<license>BSD</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>cmake_modules</build_depend>
<build_depend>eigen</build_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend>message_generation</build_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>visualization_msgs</build_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend>actionlib</build_depend>
<build_depend>actionlib_msgs</build_depend>
<run_depend>geometry_msgs</run_depend>
<run_depend>message_runtime</run_depend>
<run_depend>roscpp</run_depend>
<run_depend>rospy</run_depend>
<run_depend>sensor_msgs</run_depend>
<run_depend>visualization_msgs</run_depend>
<run_depend>geometry_msgs< ...
Are you sure you've followed all the steps in creating action messages and compiling the action?
Also, the action file has a
bool
which is astd_msgs
; in CMakeLists perhaps you should add that infind_package(catkin REQUIRED COMPONENTS ...)
?Actually indeed the problem was that I forgot to define the std_msgs. I also added <run_depend>message_generation</run_depend> in the package.xml file. Thank you for your answer
Congratulations. If you like, you can write your own answer and check the box for resolution. It will help others who follow.