ROS- catkin build error of "no such file or directory" when using a message from another package

17 views Asked by At

I have been trying to use a custom message called sPoses from one package (jackal_2dnav) in another (explore) in the same ROS workspace, but I have been unable to get it to work. I added jackal_2dnav as a dependency for explore in its package.xml, but when I would run catkin build, I would get the following error-

In file included from /home/conlab/ssv2_ws/src/m-explore/explore/src/explore.cpp:38:
/home/conlab/ssv2_ws/src/m-explore/explore/include/explore/explore.h:54:10: fatal error: jackal_2dnav/sPoses.h: No such file or directory
   54 | #include <jackal_2dnav/sPoses.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/explore.dir/build.make:95: CMakeFiles/explore.dir/src/explore.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2644: CMakeFiles/explore.dir/all] Error 2
make: *** [Makefile:160: all] Error 2

And when I try adding jackal_2dnav to explore_lite's CMakeLists.txt, under both find_package and catkin_package, I get the following error instead

CMake Error at /home/conlab/ssv2_ws/devel/share/jackal_2dnav/cmake/jackal_2dnavConfig.cmake:173 (message):
  Project 'explore_lite' tried to find library 'jackal_2dnav'.  The library
  is neither a target nor built/installed properly.  Did you compile project
  'jackal_2dnav'? Did you find_package() it before the subdirectory
  containing its code is included?
Call Stack (most recent call first):
  /opt/ros/noetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package)
  CMakeLists.txt:5 (find_package)

I've tried the fixes I've seen in similar questions, but they haven't worked. Does anyone know how I can fix this?

The file tree is something like this-

-workspace
  -src

    -jackal_2dnav (the package whose message I would like to use)
      -msg
        -sPoses.msg (the message I would like to use)
      -include
      -launch
      -params
      -src
      -CMakeLists.txt
      -package.xml

    -explore_lite (the package I would like to use the message in)
      -m-explore
        -explore
          -include
          -launch
          -src
          -CMakeLists.txt
          -package.xml
        -map_merge (an unrelated package)

As for the CMakeLists.txt, the one for explore is shown below

cmake_minimum_required(VERSION 3.1)
project(explore_lite)

## Find catkin macros and libraries
find_package(catkin REQUIRED COMPONENTS
  actionlib
  actionlib_msgs
  costmap_2d
  geometry_msgs
  map_msgs
  move_base_msgs
  nav_msgs
  roscpp
  std_msgs
  tf
  visualization_msgs

  jackal_2dnav
)

###################################
## catkin specific configuration ##
###################################
catkin_package(
  CATKIN_DEPENDS
    actionlib
    actionlib_msgs
    costmap_2d
    geometry_msgs
    map_msgs
    move_base_msgs
    nav_msgs
    roscpp
    std_msgs
    tf
    visualization_msgs 

    jackal_2dnav   
)

###########
## Build ##
###########
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

## Specify additional locations of header files
include_directories(
  ${catkin_INCLUDE_DIRS}
  include
)

add_executable(explore
  src/costmap_client.cpp
  src/explore.cpp
  src/frontier_search.cpp
)

add_dependencies(explore ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
add_dependencies(explore ${catkin_EXPORTED_TARGETS})

target_link_libraries(explore ${catkin_LIBRARIES})

#############
## Install ##
#############

# install nodes
install(TARGETS explore
  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

# install roslaunch files
install(DIRECTORY launch/
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch
)

#############
## Testing ##
#############
if(CATKIN_ENABLE_TESTING)
  find_package(roslaunch REQUIRED)

  # test all launch files
  roslaunch_add_file_check(launch)
endif()

And the package.xml file is

<?xml version="1.0"?>
<package format="2">
  <name>explore_lite</name>
  <version>2.1.4</version>

  <description>Lightweight frontier-based exploration.</description>

  <author email="[email protected]">Jiri Horner</author>
  <maintainer email="[email protected]">Jiri Horner</maintainer>
  <license>BSD</license>
  <url>http://wiki.ros.org/explore_lite</url>

  <!-- acknowledgements
  <author>Charles DuHadway</author>
  <url>http://ros.org/wiki/explore</url>
  <author>Paul Bovbel</author>
  <url>https://github.com/paulbovbel/frontier_exploration</url>
  -->
  <buildtool_depend>catkin</buildtool_depend>
  
  <depend>jackal_2dnav</depend>

  <depend>roscpp</depend>
  <depend>std_msgs</depend>
  <depend>move_base_msgs</depend>
  <depend>visualization_msgs</depend>
  <depend>geometry_msgs</depend>
  <depend>map_msgs</depend>
  <depend>nav_msgs</depend>
  <depend>actionlib_msgs</depend>
  <depend>tf</depend>
  <depend>costmap_2d</depend>
  <depend>actionlib</depend>

  <test_depend>roslaunch</test_depend>
  
</package>

I would really appreciate it if someone could point out what I am doing wrong.

0

There are 0 answers