紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
CMake编译错误
-
前置操作
安装carotgraphersudo apt install ros-foxy-cartographer sudo apt install ros-foxy-cartographer-ros
然后在fishbot_ws工作空间创建fishbot_cartographer功能包
ros2 pkg create fishbot_cartographer
执行编译命令
colcon build --packages-select fishbot_cartographer
CMakeLists.txt文件内容如下
cmake_minimum_required(VERSION 3.5) project(fishbot_cartographer) install( DIRECTORY config launch rviz DESTINATION share/${PROJECT_NAME} ) # Default to C99 if(NOT CMAKE_C_STANDARD) set(CMAKE_C_STANDARD 99) endif() # Default to C++14 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() # find dependencies find_package(ament_cmake REQUIRED) # uncomment the following section in order to fill in # further dependencies manually. # find_package(<dependency> REQUIRED) if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) # the following line skips the linter which checks for copyrights # uncomment the line when a copyright and license is not present in all source files #set(ament_cmake_copyright_FOUND TRUE) # the following line skips cpplint (only works in a git repo) # uncomment the line when this package is not in a git repo #set(ament_cmake_cpplint_FOUND TRUE) ament_lint_auto_find_test_dependencies() endif() ament_package()
编译错误内容如下
Starting >>> fishbot_cartographer --- stderr: fishbot_cartographer Traceback (most recent call last): File "/opt/ros/foxy/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py", line 21, in <module> from catkin_pkg.package import parse_package_string ModuleNotFoundError: No module named 'catkin_pkg' CMake Error at /opt/ros/foxy/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:94 (message): execute_process(/home/ros2/miniconda3/bin/python3 /opt/ros/foxy/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py /home/ros2/fishbot_ws/src/fishbot_cartographer/package.xml /home/ros2/fishbot_ws/build/fishbot_cartographer/ament_cmake_core/package.cmake) returned error code 1 Call Stack (most recent call first): /opt/ros/foxy/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:49 (_ament_package_xml) /opt/ros/foxy/share/ament_lint_auto/cmake/ament_lint_auto_find_test_dependencies.cmake:31 (ament_package_xml) CMakeLists.txt:37 (ament_lint_auto_find_test_dependencies) --- Failed <<< fishbot_cartographer [0.63s, exited with code 1] Summary: 0 packages finished [0.85s] 1 package failed: fishbot_cartographer 1 package had stderr output: fishbot_cartographer
新建功能包无任何操作,编译也是这个错误。
-
@271658536 在 CMake编译错误 中说:
ModuleNotFoundError: No module named 'catkin_pkg'
已经解决,解决方法原文如下:
https://blog.csdn.net/qq_27865227/article/details/122609055 -