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

    ROS2入门篇第3章-自定义接口RCLCPP实战colcon build失败,找不到功能包

    已定时 已固定 已锁定 已移动 未解决
    ROS 2相关问题
    ros2编译 ros2节点通讯 ros2humble
    6
    7
    1.2k
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 15971956291
      1597195629
      最后由 编辑

      一直按着鱼哥的教材走的,这是colcon build之后终端显示的错误,好像是找不到example_ros2_interfaces这个功能包,希望大佬帮解决一下

      gaozhihao@gaozhihao-virtual-machine:~/Desktop/d2lros2/chapt3/chapt3_ws$ colcon build --packages-up-to example_interfaces_rclcpp
      Starting >>> example_interfaces_rclcpp
      --- stderr: example_interfaces_rclcpp                         
      CMake Error at CMakeLists.txt:11 (find_package):
        By not providing "Findexample_ros2_interfaces.cmake" in CMAKE_MODULE_PATH
        this project has asked CMake to find a package configuration file provided
        by "example_ros2_interfaces", but CMake did not find one.
      
        Could not find a package configuration file provided by
        "example_ros2_interfaces" with any of the following names:
      
          example_ros2_interfacesConfig.cmake
          example_ros2_interfaces-config.cmake
      
        Add the installation prefix of "example_ros2_interfaces" to
        CMAKE_PREFIX_PATH or set "example_ros2_interfaces_DIR" to a directory
        containing one of the above files.  If "example_ros2_interfaces" provides a
        separate development package or SDK, be sure it has been installed.
      
      
      gmake: *** [Makefile:308:cmake_check_build_system] 错误 1
      ---
      Failed   <<< example_interfaces_rclcpp [0.85s, exited with code 2]
      
      Summary: 0 packages finished [1.20s]
        1 package failed: example_interfaces_rclcpp
        1 package had stderr output: example_interfaces_rclcpp
      
      
      1 条回复 最后回复 回复 引用 0
      • 杜守钰杜
        杜守钰
        最后由 编辑

        你能提供以下你的cmake 文件吗?

        15971956291 29378176392 2 条回复 最后回复 回复 引用 0
        • 15971956291
          1597195629 @杜守钰
          最后由 编辑

          @杜守钰

          cmake_minimum_required(VERSION 3.8)
          project(example_interfaces_rclcpp)
          
          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)
          find_package(rclcpp REQUIRED)
          find_package(example_ros2_interfaces REQUIRED)
          
          
          if(BUILD_TESTING)
            find_package(ament_lint_auto REQUIRED)
            # the following line skips the linter which checks for copyrights
            # comment the line when a copyright and license is added to all source files
            set(ament_cmake_copyright_FOUND TRUE)
            # the following line skips cpplint (only works in a git repo)
            # comment the line when this package is in a git repo and when
            # a copyright and license is added to all source files
            set(ament_cmake_cpplint_FOUND TRUE)
            ament_lint_auto_find_test_dependencies()
          endif()
          
          ament_package()
          
          add_executable(example_interfaces_robot_01 src/example_interfaces_robot_01.cpp)
          target_include_directories(example_interfaces_robot_01 PUBLIC
            $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
            $<INSTALL_INTERFACE:include>)
          target_compile_features(example_interfaces_robot_01 PUBLIC c_std_99 cxx_std_17)  # Require C99 and C++17
          ament_target_dependencies(
            example_interfaces_robot_01
            "rclcpp"
            "example_ros2_interfaces"
          )
          
          install(TARGETS example_interfaces_robot_01
            DESTINATION lib/${PROJECT_NAME})
          
          add_executable(example_interfaces_control_01 src/example_interfaces_control_01.cpp)
          target_include_directories(example_interfaces_control_01 PUBLIC
            $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
            $<INSTALL_INTERFACE:include>)
          target_compile_features(example_interfaces_control_01 PUBLIC c_std_99 cxx_std_17)  # Require C99 and C++17
          ament_target_dependencies(
            example_interfaces_control_01
            "rclcpp"
            "example_ros2_interfaces"
          )
            
          install(TARGETS example_interfaces_control_01
            DESTINATION lib/${PROJECT_NAME})
          
          小鱼小 1 条回复 最后回复 回复 引用 0
          • 小鱼小
            小鱼 技术大佬 @1597195629
            最后由 编辑

            @1597195629 在 ROS2入门篇第3章-自定义接口RCLCPP实战colcon build失败,找不到功能包 中说:

            ament_package()

            这句话放到最后,这句话前的指令才会被ros2认可

            新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

            1 条回复 最后回复 回复 引用 0
            • 29378176392
              2937817639 @杜守钰
              最后由 编辑

              @杜守钰 uu你解决了嘛 我也是同样的问题 鱼哥说的

              ament_package()
              

              放在cmake文件的最后我依旧有同样的报错 而且我看视频里面是在该行代码之后编写的需要添加的代码 依旧colcon build成功了TT

              10903348941 1 条回复 最后回复 回复 引用 0
              • 10903348941
                HeyMad @2937817639
                最后由 编辑

                @2937817639 可以试试用SET({对应接口}_DIR /yourpath/)的方式试试,原因应该是找不到接口包的路径

                1 条回复 最后回复 回复 引用 0
                • 1
                  等待修复
                  最后由 编辑

                  此回复已被删除!
                  1 条回复 最后回复 回复 引用 0
                  • 第一个帖子
                    最后一个帖子
                  皖ICP备16016415号-7
                  Powered by NodeBB | 鱼香ROS