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

    No executable found(ros2 run的时候找不到头文件)

    已定时 已固定 已锁定 已移动
    ROS 2相关问题
    ros2humble ros2编译 python3 节点与话题
    5
    11
    3.4k
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 小鱼小
      小鱼 技术大佬 @march_xiong
      最后由 编辑

      @march_xiong 试试这个指令,看看会显示什么

      cd  src/village_wang
      mkdir build
      cd build
      cmake ..
      make
      

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

      M 1 条回复 最后回复 回复 引用 1
      • M
        march_xiong @小鱼
        最后由 march_xiong 编辑

        @小鱼
        运行上述后的结果

        ros2@ros2-virtual-machine:~/town_ws$ cd  src/village_wang
        ros2@ros2-virtual-machine:~/town_ws/src/village_wang$ mkdir build
        mkdir: 无法创建目录 "build": 文件已存在
        ros2@ros2-virtual-machine:~/town_ws/src/village_wang$ cd build
        ros2@ros2-virtual-machine:~/town_ws/src/village_wang/build$ cmake ..
        -- Found ament_cmake: 1.3.3 (/opt/ros/humble/share/ament_cmake/cmake)
        -- Found rclcpp: 16.0.3 (/opt/ros/humble/share/rclcpp/cmake)
        -- Found rosidl_generator_c: 3.1.4 (/opt/ros/humble/share/rosidl_generator_c/cmake)
        -- Found rosidl_adapter: 3.1.4 (/opt/ros/humble/share/rosidl_adapter/cmake)
        -- Found rosidl_generator_cpp: 3.1.4 (/opt/ros/humble/share/rosidl_generator_cpp/cmake)
        -- Using all available rosidl_typesupport_c: rosidl_typesupport_fastrtps_c;rosidl_typesupport_introspection_c
        -- Using all available rosidl_typesupport_cpp: rosidl_typesupport_fastrtps_cpp;rosidl_typesupport_introspection_cpp
        -- Found rmw_implementation_cmake: 6.1.1 (/opt/ros/humble/share/rmw_implementation_cmake/cmake)
        -- Found rmw_fastrtps_cpp: 6.2.2 (/opt/ros/humble/share/rmw_fastrtps_cpp/cmake)
        -- Using RMW implementation 'rmw_fastrtps_cpp' as default
        -- Found ament_lint_auto: 0.12.5 (/opt/ros/humble/share/ament_lint_auto/cmake)
        -- Added test 'cppcheck' to perform static code analysis on C / C++ code
        -- Configured cppcheck include dirs: 
        -- Configured cppcheck exclude dirs and/or files: 
        -- Added test 'lint_cmake' to check CMake code style
        -- Added test 'uncrustify' to check C / C++ code style
        -- Configured uncrustify additional arguments: 
        -- Added test 'xmllint' to check XML markup files
        -- Configuring done
        -- Generating done
        -- Build files have been written to: /home/ros2/town_ws/src/village_wang/build
        ros2@ros2-virtual-machine:~/town_ws/src/village_wang/build$ make
        ros2@ros2-virtual-machine:~/town_ws/src/village_wang/build$ 
        

        然后我在新的终端重新执行ros2 run程序,结果

        ros2@ros2-virtual-machine:~/town_ws$ colcon build --packages-select village_wang
        Starting >>> village_wang
        Finished <<< village_wang [0.17s]                  
        
        Summary: 1 package finished [0.35s]
        ros2@ros2-virtual-machine:~/town_ws$ source install/setup.bash
        ros2@ros2-virtual-machine:~/town_ws$ ros2 pkg list | grep vill
        village_li
        village_wang
        ros2@ros2-virtual-machine:~/town_ws$ ros2 run village_wang wang2_node
        No executable found
        ros2@ros2-virtual-machine:~/town_ws$ 
        

        发现报相同错误

        No executable found
        

        后续发现找不到wang2这个节点

        ros2@ros2-virtual-machine:~/town_ws$ ros2 node list
        /li4
        ros2@ros2-virtual-machine:~/town_ws$ ros2 node info /wang2
        Unable to find node '/wang2'
        ros2@ros2-virtual-machine:~/town_ws$ 
        
        醉后不知天在水醉 2 条回复 最后回复 回复 引用 0
        • 醉后不知天在水醉
          醉后不知天在水 活跃VIP @march_xiong
          最后由 编辑

          @march_xiong 1.尝试检查一下CMakeLists.txt是否写入
          2.工作空间是否创建错误,
          文件目录为.
          └── src
          └── example_topic_rclcpp
          ├── CMakeLists.txt
          ├── include
          │ └── example_topic_rclcpp
          ├── package.xml
          └── src
          └── topic_publisher_01.cpp

          5 directories, 3 files

          1 条回复 最后回复 回复 引用 0
          • 醉后不知天在水醉
            醉后不知天在水 活跃VIP @march_xiong
            最后由 编辑

            @march_xiong 具体参考https://fishros.com/d2lros2foxy/#/chapt3/3.6.1%E5%88%9B%E5%BB%BA%E4%B8%80%E4%B8%AAC++%E5%8A%9F%E8%83%BD%E5%8C%85

            M 1 条回复 最后回复 回复 引用 0
            • M
              march_xiong @醉后不知天在水
              最后由 编辑

              @醉后不知天在水
              目录如下
              334600ee-0a51-4b94-a7a3-2f64dab28dce-5c1cf1840ae7180ecfea7ea264ede0f.png

              就是多了个构造build后的文件夹

              重新编译后报错情况如下

              ros2@ros2-virtual-machine:~/town_ws$ colcon build --packages-select village_wang
              Starting >>> village_wang
              --- stderr: village_wang                         
              CMake Error at /opt/ros/humble/share/ament_cmake_core/cmake/environment_hooks/ament_environment_hooks.cmake:29 (message):
                ament_environment_hooks() must be called before
                ament_generate_package_environment() (which is invoked by ament_package())
              Call Stack (most recent call first):
                /opt/ros/humble/share/ament_cmake_core/cmake/environment_hooks/ament_cmake_environment_hooks_package_hook.cmake:20 (ament_environment_hooks)
                /opt/ros/humble/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:48 (include)
                /opt/ros/humble/share/ament_cmake_core/cmake/core/ament_package.cmake:66 (ament_execute_extensions)
                CMakeLists.txt:33 (ament_package)
              
              
              gmake: *** [Makefile:226:cmake_check_build_system] 错误 1
              ---
              Failed   <<< village_wang [1.41s, exited with code 2]
              
              Summary: 0 packages finished [1.76s]
                1 package failed: village_wang
                1 package had stderr output: village_wang
              

              主要是这块

              CMake Error at /opt/ros/humble/share/ament_cmake_core/cmake/environment_hooks/ament_environment_hooks.cmake:29 (message):
                ament_environment_hooks() must be called before
                ament_generate_package_environment() (which is invoked by ament_package())
              

              就是这个环境的声明问题,不过CMakelist中的这行代码是照着视频敲的
              CMakelist进行了读写

              cmake_minimum_required(VERSION 3.8)
              project(village_wang)
              
              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)
              
              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(wang2_node src/wang2.cpp)
              ament_target_dependencies(wang2_node rclcpp)
              
              install(TARGETS wang2_node
              DESTINATION lib/${PROJECT_NAME}
              )
              
              

              最下面的三段是视频的教程
              这个

              ament_package()
              

              网上查找结果

              因为ament package是构建系统独立的,所以有各种各样的ament包,比如ament CMake package、ament Python package等。
              

              所以这个报错,不知道应该如何解决

              小鱼小 1 条回复 最后回复 回复 引用 0
              • 小鱼小
                小鱼 技术大佬 @march_xiong
                最后由 编辑

                @march_xiong 将ament_package() 移到最后一行

                cmake_minimum_required(VERSION 3.8)
                project(example_cpp)
                
                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)
                
                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()
                
                add_executable(node_01 src/node_01.cpp)
                ament_target_dependencies(node_01 rclcpp)
                
                add_executable(node_03 src/node_03.cpp)
                ament_target_dependencies(node_03 rclcpp)
                
                install(TARGETS
                  node_01
                  DESTINATION lib/${PROJECT_NAME}
                )
                
                install(TARGETS
                  node_03
                  DESTINATION lib/${PROJECT_NAME}
                )
                
                
                ament_package()
                

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

                M 13183088151 2 3 条回复 最后回复 回复 引用 0
                • M
                  march_xiong @小鱼
                  最后由 编辑

                  @小鱼
                  更改后确实运行正常了 小鱼好厉害👍 😊
                  不过有点好奇这个库要最后声明么?

                  1 条回复 最后回复 回复 引用 0
                  • 13183088151
                    学不会的ROS2 @小鱼
                    最后由 编辑

                    @小鱼 cmake_minimum_required(VERSION 3.8)
                    project(cpp01_launch)

                    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)

                    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()

                    install(DIRECTORY launch DESTINATION share/${PROJECT_NAME})
                    ament_package()

                    我的ament_package()就是在最后一行 为什么运行后的结果还是No executable found

                    1 条回复 最后回复 回复 引用 0
                    • 2
                      2041525450 @小鱼
                      最后由 编辑

                      @小鱼 9be6f6e9-4f9b-40d3-9eb5-fb37af575e8d-image.png ament_package()在最后一行还是不行

                      小鱼小 1 条回复 最后回复 回复 引用 0
                      • 小鱼小
                        小鱼 技术大佬 @2041525450
                        最后由 编辑

                        @2041525450 我保证,视频和书里绝对没有你敲的这句命令

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

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