ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Custom action message can't be found during compilation

asked 2021-04-29 09:43:08 -0500

AlexandrosNic gravatar image

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< ...
(more)
edit retag flag offensive close merge delete

Comments

2

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 a std_msgs; in CMakeLists perhaps you should add that in find_package(catkin REQUIRED COMPONENTS ...)?

abhishek47 gravatar image abhishek47  ( 2021-04-30 04:40:44 -0500 )edit
1

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

AlexandrosNic gravatar image AlexandrosNic  ( 2021-04-30 06:48:37 -0500 )edit
1

Congratulations. If you like, you can write your own answer and check the box for resolution. It will help others who follow.

miura gravatar image miura  ( 2021-04-30 22:03:34 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2021-05-03 03:29:47 -0500

AlexandrosNic gravatar image

I fixed it through your recommendations. First I forgot to define the std_msgs (for the boolean) and include them in the package.xml. Second, I added <run_depend>message_generation</run_depend> in the package.xml file. Thank you for your replies.

edit flag offensive delete link more
0

answered 2021-04-29 12:58:34 -0500

miura gravatar image

Try this.

add_dependencies(corner_action_server ${laser_line_extraction_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
add_dependencies(corner_action_client ${laser_line_extraction_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

ref: http://docs.ros.org/en/indigo/api/cat...

edit flag offensive delete link more

Comments

Thank you for your answer @miura, but it didn't work.

AlexandrosNic gravatar image AlexandrosNic  ( 2021-04-30 03:37:54 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-04-29 09:43:08 -0500

Seen: 314 times

Last updated: May 03 '21