鱼香ROS社区
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    • 注册
    • 登录
    紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
    提问前必看的发帖注意事项: 社区问答规则(小鱼个人)更新 | 高质量帖子发布指南

    CMake编译错误

    已定时 已固定 已锁定 已移动 已解决
    综合问题
    cmake ros2 foxy
    1
    2
    655
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 2716585362
      ℡﹏smˋ背靠背の承诺
      最后由 小鱼 编辑

      前置操作
      安装carotgrapher

      sudo 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
      
      

      新建功能包无任何操作,编译也是这个错误。

      1 条回复 最后回复 回复 引用 0
      • 2716585362
        ℡﹏smˋ背靠背の承诺
        最后由 编辑

        @271658536 在 CMake编译错误 中说:

        ModuleNotFoundError: No module named 'catkin_pkg'

        已经解决,解决方法原文如下:
        https://blog.csdn.net/qq_27865227/article/details/122609055

        1 条回复 最后回复 回复 引用 0
        • 2716585362 271658536 将这个主题标记为已解决,在
        • 第一个帖子
          最后一个帖子
        皖ICP备16016415号-7
        Powered by NodeBB | 鱼香ROS