Bryan Liu
Bryan Liu

Reputation: 13

ROS2 humble no such file but installed confirmed

I got a package from friend need to build it at ROS2 humble. I use this docker image in the vs code. https://docs.ros.org/en/foxy/How-To-Guides/Run-2-nodes-in-single-or-separate-docker-containers.html

But I got "no such file" error: enter image description here

However, I tried ros2 pkg list. I did see the "pcl_conversions" in the list. I use "ros2 pkg prefix pcl_conversions", it shows path is /opt/ros/humble

How should I link it to the ros2 colcon build ? Could you show me ??

Thank you.

Here is my cmake_list

#cmake_minimum_required(VERSION 2.8.3)
cmake_minimum_required(VERSION 3.5)
project(neuvition_driver)
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 14)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic )
endif()

   
set  (LIBCURL ${PROJECT_SOURCE_DIR}/lib/libcurl.so)
set  (LIBNEUSDK ${PROJECT_SOURCE_DIR}/lib/libneusdk_boost_1_70.so)
set(OpenCV_DIR /usr/share/OpenCV)
set(pcl_conversions_DIR  /opt/ros/humble/include/)
#find_package(catkin REQUIRED COMPONENTS roscpp std_msgs)
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(image_transport REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(PCL REQUIRED)
#find_package(PCL REQUIRED COMPONENT common io)
#find_package(PCL 1.3 REQUIRED COMPONENTS common io)
find_package(OpenCV 4 REQUIRED)
find_package(Boost REQUIRED COMPONENTS system thread)
find_package(pcl_conversions REQUIRED PATHS /opt/ros/humble/)


#catkin_package()
#include_directories(${catkin_INCLUDE_DIRS})
include_directories(include ${OpenCV_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS}  ${Boost_INCLUDE_DIRS}) 
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS}) 
add_executable(neuvition_driver neuvition_node.cpp driver.cpp)
#target_link_libraries(talker ${catkin_LIBRARIES})


target_link_libraries(neuvition_driver
${catkin_LIBRARIES} 
  ${PCL_LIBRARIES}
  ${OpenCV_LIBS}
  ${Boost_LIBRARIES}
  ${LIBCURL}
  ${LIBNEUSDK}
  ${PCL_LIBRARIES}
)

ament_target_dependencies(neuvition_driver
  rclcpp
  std_msgs sensor_msgs image_transport cv_bridge)
  
#install(TARGETS talker
#  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
install(TARGETS neuvition_driver
  DESTINATION lib/${PROJECT_NAME})
  
install(TARGETS neuvition_driver
  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
 )

install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink
                        ${CMAKE_INSTALL_PREFIX}/${CATKIN_PACKAGE_BIN_DESTINATION}/libneusdk_boost_1_70.so
                        ${CMAKE_INSTALL_PREFIX}/${CATKIN_PACKAGE_LIB_DESTINATION}/libneusdk_boost_1_70.so)"
)

 
install(DIRECTORY include/
  DESTINATION include)
ament_export_include_directories(include)
ament_export_dependencies(std_msgs)
ament_package()

and my package.xml

<package format="2">
  <name>neuvition_driver</name>
  <version>0.9.4</version>
  <description>Examples of minimal subscribers</description>
  <maintainer email="[email protected]">Jacob Perron</maintainer>
  <license>Apache License 2.0</license>
  <author>Mikael Arguedas</author>
  <author>Morgan Quigley</author>

  <buildtool_depend>ament_cmake</buildtool_depend>
  <buildtool_depend>rosidl_default_generators</buildtool_depend>
  <build_depend>rclcpp</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>sensor_msgs</build_depend>
  <build_depend>image_transport</build_depend>
  <build_depend>cv_bridge</build_depend>
  <build_depend>pcl_conversion</build_depend>
  <exec_depend>rclcpp</exec_depend>
  <exec_depend>std_msgs</exec_depend>
  <exec_depend>pcl_conversion</exec_depend>
  <exec_depend>sensor_msgs</exec_depend>
  <exec_depend>image_transport</exec_depend>
  <exec_depend>cv_bridge</exec_depend>
  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>

I tried to reinstall with " sudo apt-get install ros-humble-pcl-conversions" but it said I already installed.

Upvotes: 0

Views: 1874

Answers (1)

Alesof
Alesof

Reputation: 341

You need to link the library to the executable. Something like this:

add_executable(neuvition_driver neuvition_node.cpp driver.cpp)
ament_target_dependencies(neuvition_driver
  rclcpp
  std_msgs 
  sensor_msgs 
  image_transport 
  cv_bridge
  pcl_conversions
  )

or using target_link_libraries. I don't know what the other libraries the node depends on, you should add those too.

It also seems to me that you're trying to redefine the cmakelist starting from a ROS version of it. There are a lot of "catkin" keywords, ROS2 uses ament. I don't think it's a good idea mixing them.

Notice also that in your package.xml you are defining:

<build_depend>pcl_conversion</build_depend>
<exec_depend>pcl_conversion</exec_depend>

whilst I think your library is pcl_conversions.

Upvotes: 1

Related Questions