英文:
ROS2 humble no such file but installed confirmed
问题
我收到了来自朋友的一个包裹,需要在ROS2 humble上构建它。
我在vs code中使用这个Docker镜像。
https://docs.ros.org/en/foxy/How-To-Guides/Run-2-nodes-in-single-or-separate-docker-containers.html
但是我遇到了"no such file"错误:
查看图像描述
然而,我尝试了ros2 pkg list。
我确实在列表中看到了"pcl_conversions"。
我使用"ros2 pkg prefix pcl_conversions",
它显示路径为/opt/ros/humble。
我应该如何将它链接到ros2 colcon build?
你能给我看看吗?
谢谢。
这是我的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()
和我的package.xml
<package format="2">
<name>neuvition_driver</name>
<version>0.9.4</version>
<description>Examples of minimal subscribers</description>
<maintainer email="jacob@openrobotics.org">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 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="jacob@openrobotics.org">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.
答案1
得分: 0
您需要将库链接到可执行文件。类似这样:
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
)
或使用 target_link_libraries。我不知道该节点依赖的其他库,你也应该添加它们。
我还觉得你在尝试重新定义 CMakeLists,以 ROS 版本为基础。有很多“catkin”关键字,ROS2 使用 ament。我不认为混合它们是个好主意。
请注意,您在 package.xml 中定义了:
<build_depend>pcl_conversion</build_depend>
<exec_depend>pcl_conversion</exec_depend>
而我认为您的库应该是 pcl_conversions。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论