Catkin build can't find package's third party libraries

asked 2022-03-26 16:44:50 -0500

bonjiman gravatar image

Hi everyone,

I'm using ROS to interface with a lidar, and I'm trying to write a nodelet that does some processing on the lidar pointcloud. The lidar manufacturers provide a ROS driver and library on their GitHub. Their ROS drivers have two different places where header files are located: [ROS_workspace]/src/cepton_ros/include/cepton_ros and [ROS_workspace]/src/cepton_ros/third_party/cepton_sdk/include

I am writing my own package that uses the cepton_ros package as a dependency. When I write my code that references the cepton_ros package, I always get an error. Basically, catkin has no issues finding cepton_ros/include/cepton_ros, but then it can't seem to locate cepton_ros/third_party/**. I can't understand why this isn't working because the CMakeLists.txt of the cepton_ros package should be exporting its required libraries in that file's call to the catkin_package() function.

By the way, I am using ROS Noetic on Ubuntu 20.04 LTS

Steps I took:

  1. List item
  2. Created a new ros catkin workspace called "new_ws"
  3. Downloaded the cepton_ros package (version 1.18.1) and placed it in my "new_ws/src" directory. (On my system I have to change line 26 of the CMakeLists to get it to compile using C++14)
  4. Created a new package "lidar_test" and added cepton_ros, pcl_ros, pcl_conversions, roscpp, nodelet, pluginlib, and sensor_msgs as dependencies
  5. Double-checked that the package.xml for "lidar_test" agrees with the above.
  6. Created a test.cpp file in "lidar_test/src" and added a SINGLE line to the file: "#include "cepton_ros/point.h"
  7. Used ROS's provided sample CMakeLists.txt to try to link all the dependencies (I think this is where the mistake is)
  8. Used "catkin build" in the terminal to build the cepton_ros and lidar_test packages. Understandably, the cepton_ros package builds just fine but the lidar_test package gets an error because catkin apparently can't locate the cepton_ros third party libraries
In file included from /home/autodrive/new_ws/src/lidar_test/src/test.cpp:1:
/home/autodrive/new_ws/src/cepton_ros/include/cepton_ros/point.hpp:7:10: fatal error: cepton_sdk_util.hpp: No such file or directory
    7 | #include <cepton_sdk_util.hpp> 

My test.cpp (only 1 line):

1    #include "cepton_ros/point.h"

My Package.xml: Link to Screenshot of my package.xml dependencies

My CMakeLists.txt:

cmake_minimum_required(VERSION 3.0.2)
project(lidar_test)

## Compile as C++14
add_compile_options(-std=c++14)

## Create a helpful tag for the project directories
set(LIDAR_TEST_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}")

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  cepton_ros
  pcl_conversions
  pcl_ros
  roscpp
  nodelet
  pluginlib
  sensor_msgs
)

## System dependencies are found with CMake's conventions
find_package(Boost REQUIRED COMPONENTS system)

## Generate added messages and services with any dependencies listed here
generate_messages(
  DEPENDENCIES
  sensor_msgs  # Or other packages containing msgs
)

catkin_package(
  INCLUDE_DIRS include
  CATKIN_DEPENDS cepton_ros pcl_conversions pcl_ros roscpp
)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
  ${Boost_INCLUDE_DIRS}
)

## Declare a C++ library
set(LIDAR_TEST_LIBRARIES "")

add_library(${PROJECT_NAME}
  "${LIDAR_TEST_SOURCE_DIR}/src/test.cpp"
)
list(APPEND LIDAR_TEST_LIBRARIES ${PROJECT_NAME})

foreach(name IN LISTS LIDAR_TEST_LIBRARIES)
  ## Add cmake target ...
(more)
edit retag flag offensive close merge delete

Comments

1

This won't immediately help you solve this, but I wanted to draw attention to the fact that "catkin build" never "finds" anything.

Catkin drives CMake, which drives your compiler. If you get include errors, it's your compiler complaining. Not CMake, nor Catkin.

gvdhoorn gravatar image gvdhoorn  ( 2022-03-29 03:22:39 -0500 )edit