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

    MicoROS自定义服务接口

    已定时 已固定 已锁定 已移动
    FishBot二驱机器人
    fishbot 主控板 micoros
    3
    9
    449
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 2
      2996724802 年度VIP
      最后由 编辑

      我在删除.pio/libdeps/featheresp32/micro_ros_platformio/libmicroros文件夹,使用Ctrl+Alt+B重新重新编译工程后报错

      • 正在执行任务: platformio run

      Processing featheresp32 (platform: espressif32; board: featheresp32; framework: arduino)

      Verbose mode can be enabled via -v, --verbose option
      CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/featheresp32.html
      PLATFORM: Espressif 32 (6.9.0) > Adafruit ESP32 Feather
      HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
      DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
      PACKAGES:

      • framework-arduinoespressif32 @ 3.20017.0 (2.0.17)
      • tool-esptoolpy @ 1.40501.0 (4.5.1)
      • toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
        LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
        LDF Modes: Finder ~ chain, Compatibility ~ soft
        Installing importlib-resources with pip at PlatformIO environment
        /home/chen/.platformio/penv/bin/python3 -m pip install importlib-resources
        Requirement already satisfied: importlib-resources in /home/chen/.platformio/penv/lib/python3.10/site-packages (6.4.5)
        Installing pyyaml with pip at PlatformIO environment
        /home/chen/.platformio/penv/bin/python3 -m pip install pyyaml
        Requirement already satisfied: pyyaml in /home/chen/.platformio/penv/lib/python3.10/site-packages (6.0.2)
        Installing markupsafe==2.0.1 with pip at PlatformIO environment
        /home/chen/.platformio/penv/bin/python3 -m pip install markupsafe==2.0.1
        Requirement already satisfied: markupsafe==2.0.1 in /home/chen/.platformio/penv/lib/python3.10/site-packages (2.0.1)
        Configuring featheresp32 with transport serial
        Downloading micro-ROS dev dependencies
        ament_cmake clone failed:
        正克隆到 '/home/chen/fish/example14_custom_interface/.pio/libdeps/featheresp32/micro_ros_platformio/build/dev/src/ament_cmake'...
        fatal: 无法访问 'http://github.fishros.org/https://github.com/ament/ament_cmake/':Recv failure: 连接被对方重置

      =============================================== [FAILED] Took 2.71 seconds ===============================================
      请问什么原因,怎么解决,弄了一个晚上了

      值得一提的是我的很多库必须显式调用
      lib_deps =
      https://gitee.com/ohhuo/micro_ros_platformio.git
      adafruit/Adafruit SSD1306@^2.5.7
      Adafruit GFX Library@1.11.5
      Adafruit SSD1306
      Adafruit BusIO
      Wire
      SPI

      小鱼小 1 条回复 最后回复 回复 引用 0
      • 小伊小
        机器人小伊
        最后由 编辑

        这个链接可能存在安全风险,为了保护您的设备和数据安全,请避免访问此链接。


        以上为生成回答,仅供参考~

        我是小伊,已接入ChatGpt,所有回复,仅供参考~

        2 1 条回复 最后回复 回复 引用 0
        • 2
          2996724802 年度VIP @小伊
          最后由 编辑

          @小伊 对了如果不删除这个文件直接编译初始main函数是不会报错的,
          但是加上代码后
          #include <Arduino.h>
          #include <micro_ros_platformio.h>

          #include <rcl/rcl.h>
          #include <rclc/rclc.h>
          #include <rclc/executor.h>
          #include <micro_ros_utilities/string_utilities.h>

          #include "Wire.h"
          #include <Adafruit_GFX.h> // 加载Adafruit_GFX库
          #include <Adafruit_SSD1306.h> // 加载Adafruit_SSD1306库

          #include <fishbot_interfaces/srv/oled_control.h> // 添加接口

          rclc_executor_t executor;
          rclc_support_t support;
          rcl_allocator_t allocator;
          rcl_node_t node;
          // 定义服务
          rcl_service_t service;

          // 服务请求和返回消息定义
          fishbot_interfaces__srv__OledControl_Request req;
          fishbot_interfaces__srv__OledControl_Response res;
          .........
          后会显示找不到#include <fishbot_interfaces/srv/oled_control.h>
          我看了一下我的.h文件在fishbot_interfaces/fishbot_interfaces/srv/oled_control.h>
          这个目录下,
          然后我把头文件改错了#include <fishbot_interfaces/fishbot_interfaces/srv/oled_control.h>
          也是报错找不到这个头文件

          1 条回复 最后回复 回复 引用 0
          • 小伊小
            机器人小伊
            最后由 编辑

            在 C++(或 Arduino 编程环境)中,包含(include)头文件时出现的路径问题通常是因为编译器没有按照你期望的路径去查找这些文件。在你的情况中,有几个可能的原因和解决方案:

            1. 头文件路径错误

            你提到头文件实际上位于 fishbot_interfaces/fishbot_interfaces/srv/oled_control.h,但你在代码中尝试使用 #include <fishbot_interfaces/srv/oled_control.h> 和 #include <fishbot_interfaces/fishbot_interfaces/srv/oled_control.h>。这两个路径都是错误的,因为它们没有正确地指向文件的位置。

            正确的包含指令应该直接指向文件相对于编译器搜索路径的位置。如果你的项目结构是这样的:

            project/
            ├── fishbot_interfaces/
            │   └── fishbot_interfaces/
            │       └── srv/
            │           └── oled_control.h
            └── src/
                └── main.cpp
            

            并且你的编译器默认搜索路径不包含 project/fishbot_interfaces/fishbot_interfaces/,你需要调整包含指令或者编译器设置。

            2. 修改包含指令

            如果你不想改变编译器的搜索路径(这通常通过IDE设置或者编译器的命令行参数来设置),你可以修改包含指令以正确反映文件的相对位置,但这通常意味着你需要使用相对路径而不是绝对路径(尽管在这里你似乎是在尝试使用“绝对”路径,但实际上是相对于某个未明确指定的根目录)。

            如果你的 main.cpp 文件在 src/ 目录下,并且头文件在 fishbot_interfaces/fishbot_interfaces/srv/ 下,你可能需要这样做(假设你的IDE或编译环境允许从项目根目录开始搜索):

            #include "fishbot_interfaces/fishbot_interfaces/srv/oled_control.h"
            

            注意这里使用了双引号 " 而不是尖括号 < 和 >。双引号会告诉编译器在当前文件所在的目录以及编译器的包含目录中查找文件,而尖括号通常用于标准库或预定义路径中的文件。

            3. 调整编译器的包含目录

            如果你使用的是像 Arduino IDE 这样的环境,你可能需要在项目设置中指定额外的库路径或包含目录。对于像 PlatformIO 这样的更灵活的IDE,你可以在 platformio.ini 文件中设置包含目录:

            lib_extra_dirs =
              fishbot_interfaces/fishbot_interfaces
            

            但请注意,这个设置可能会根据实际的文件结构和你的项目需求而有所不同。

            结论

            首先,确保你的包含指令正确指向了文件的位置。其次,考虑是否需要调整IDE或编译器的设置以包含额外的目录。如果问题仍然存在,检查是否有拼写错误或路径错误,并确保所有文件都已正确保存在预期的目录中。


            以上为生成回答,仅供参考~

            我是小伊,已接入ChatGpt,所有回复,仅供参考~

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

              @2996724802 这涉及到了重构建microros 库的问题,如果你有代理,可以尝试直接使用官方库:

              ...
              lib_deps =
              https://github.com/micro-ROS/micro_ros_platformio

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

              2 3 条回复 最后回复 回复 引用 0
              • 2
                2996724802 年度VIP @小鱼
                最后由 编辑

                @小鱼 * 正在执行任务: platformio run

                Processing featheresp32 (platform: espressif32; board: featheresp32; framework: arduino)

                Verbose mode can be enabled via -v, --verbose option
                CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/featheresp32.html
                PLATFORM: Espressif 32 (6.9.0) > Adafruit ESP32 Feather
                HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
                DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
                PACKAGES:

                • framework-arduinoespressif32 @ 3.20017.0 (2.0.17)
                • tool-esptoolpy @ 1.40501.0 (4.5.1)
                • toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
                  LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
                  LDF Modes: Finder ~ chain, Compatibility ~ soft
                  Installing importlib-resources with pip at PlatformIO environment
                  /home/chen/.platformio/penv/bin/python3 -m pip install importlib-resources
                  Requirement already satisfied: importlib-resources in /home/chen/.platformio/penv/lib/python3.10/site-packages (6.4.5)
                  Installing pyyaml with pip at PlatformIO environment
                  /home/chen/.platformio/penv/bin/python3 -m pip install pyyaml
                  Requirement already satisfied: pyyaml in /home/chen/.platformio/penv/lib/python3.10/site-packages (6.0.2)
                  Installing markupsafe==2.0.1 with pip at PlatformIO environment
                  /home/chen/.platformio/penv/bin/python3 -m pip install markupsafe==2.0.1
                  Requirement already satisfied: markupsafe==2.0.1 in /home/chen/.platformio/penv/lib/python3.10/site-packages (2.0.1)
                  Installing empy==3.3.4 with pip at PlatformIO environment
                  /home/chen/.platformio/penv/bin/python3 -m pip install empy==3.3.4
                  Requirement already satisfied: empy==3.3.4 in /home/chen/.platformio/penv/lib/python3.10/site-packages (3.3.4)
                  Configuring featheresp32 with transport serial
                  Downloading micro-ROS dev dependencies
                  - Downloaded ament_cmake
                  - Downloaded ament_lint
                  - Downloaded ament_package
                  - Downloaded googletest
                  - Downloaded ament_cmake_ros
                  - Downloaded ament_index
                  Building micro-ROS dev dependencies
                  Downloading micro-ROS library
                  - Downloaded microcdr
                  - Downloaded microxrcedds_client
                  - Downloaded rcl
                  - Downloaded rcl_action
                  - Downloaded rcl_lifecycle
                  - Downloaded rcl_yaml_param_parser (ignored)
                  - Downloaded rclc
                  - Downloaded rclc_examples (ignored)
                  - Downloaded rclc_lifecycle
                  - Downloaded rclc_parameter
                  - Downloaded micro_ros_utilities
                  - Downloaded rcutils
                  - Downloaded micro_ros_msgs
                  - Downloaded rmw_microxrcedds
                  - Downloaded rosidl_typesupport_c
                  - Downloaded rosidl_typesupport_cpp (ignored)
                  - Downloaded rosidl_typesupport_tests
                  - Downloaded rosidl_typesupport_microxrcedds_c
                  - Downloaded rosidl_typesupport_microxrcedds_cpp (ignored)
                  - Downloaded rosidl_typesupport_microxrcedds_c_tests
                  - Downloaded rosidl_typesupport_microxrcedds_cpp_tests
                  - Downloaded rosidl_typesupport_microxrcedds_test_msg
                  - Downloaded rosidl_adapter
                  - Downloaded rosidl_cli
                  - Downloaded rosidl_cmake
                  - Downloaded rosidl_generator_c
                  - Downloaded rosidl_generator_cpp (ignored)
                  - Downloaded rosidl_generator_tests
                  - Downloaded rosidl_generator_type_description
                  - Downloaded rosidl_parser
                  - Downloaded rosidl_pycommon
                  - Downloaded rosidl_runtime_c
                  - Downloaded rosidl_runtime_cpp (ignored)
                  - Downloaded rosidl_typesupport_interface
                  - Downloaded rosidl_typesupport_introspection_c
                  - Downloaded rosidl_typesupport_introspection_cpp (ignored)
                  - Downloaded rosidl_typesupport_introspection_tests
                  - Downloaded rosidl_dynamic_typesupport
                  - Downloaded rosidl_core_generators
                  - Downloaded rosidl_core_runtime
                  - Downloaded rmw
                  - Downloaded rmw_implementation_cmake
                  - Downloaded action_msgs
                  - Downloaded builtin_interfaces
                  - Downloaded composition_interfaces
                  - Downloaded lifecycle_msgs
                  - Downloaded rcl_interfaces
                  - Downloaded rosgraph_msgs
                  - Downloaded service_msgs
                  - Downloaded statistics_msgs
                  - Downloaded test_msgs
                  - Downloaded type_description_interfaces
                  - Downloaded rosidl_default_generators
                  - Downloaded rosidl_default_runtime
                  - Downloaded unique_identifier_msgs
                  - Downloaded actionlib_msgs
                  - Downloaded common_interfaces
                  - Downloaded diagnostic_msgs
                  - Downloaded geometry_msgs
                  - Downloaded nav_msgs
                  - Downloaded sensor_msgs
                  - Downloaded sensor_msgs_py
                  - Downloaded shape_msgs
                  - Downloaded std_msgs
                  - Downloaded std_srvs
                  - Downloaded stereo_msgs
                  - Downloaded trajectory_msgs
                  - Downloaded visualization_msgs
                  - Downloaded test_interface_files
                  - Downloaded rmw_implementation
                  - Downloaded test_rmw_implementation
                  - Downloaded rcl_logging_interface
                  - Downloaded rcl_logging_noop
                  - Downloaded rcl_logging_spdlog (ignored)
                  - Downloaded ros2trace
                  - Downloaded test_ros2trace
                  - Downloaded test_tracetools (ignored)
                  - Downloaded test_tracetools_launch
                  - Downloaded tracetools
                  - Downloaded tracetools_launch
                  - Downloaded tracetools_read
                  - Downloaded tracetools_test
                  - Downloaded tracetools_trace
                  Checking extra packages
                  - Adding fishbot_interfaces
                  - Adding log
                  - Adding build
                  - Adding install
                  Building micro-ROS library
                  Build mcu micro-ROS environment failed:
                  --- stderr: fishbot_interfaces
                  CMake Error at CMakeLists.txt:27 (find_package):
                  By not providing "Findrosidl_default_generators.cmake" in CMAKE_MODULE_PATH
                  this project has asked CMake to find a package configuration file provided
                  by "rosidl_default_generators", but CMake did not find one.

                Could not find a package configuration file provided by
                "rosidl_default_generators" with any of the following names:

                rosidl_default_generatorsConfig.cmake
                rosidl_default_generators-config.cmake
                

                Add the installation prefix of "rosidl_default_generators" to
                CMAKE_PREFIX_PATH or set "rosidl_default_generators_DIR" to a directory
                containing one of the above files. If "rosidl_default_generators" provides
                a separate development package or SDK, be sure it has been installed.


                Failed <<< fishbot_interfaces [0.75s, exited with code 1]

                ============================================== [FAILED] Took 87.32 seconds ==============================================

                现在又报错了这个,colcon bulid是没有报错的,但是工程编译报错了,
                我确定我有这个包,不知道是哪里没有设置好。
                这个是xml文件
                <?xml version="1.0"?>
                <?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
                <package format="3">
                <name>fishbot_interfaces</name>
                <version>0.0.0</version>
                <description>TODO: Package description</description>
                <maintainer email="chen@todo.todo">chen</maintainer>
                <license>TODO: License declaration</license>

                <buildtool_depend>ament_cmake</buildtool_depend>

                <test_depend>ament_lint_auto</test_depend>
                <test_depend>ament_lint_common</test_depend>
                <member_of_group>rosidl_interface_packages</member_of_group>'
                <export>
                <build_type>ament_cmake</build_type>
                </export>
                </package>

                这个是txt文件
                cmake_minimum_required(VERSION 3.5)
                project(fishbot_interfaces)

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

                find_package(rosidl_default_generators REQUIRED)

                rosidl_generate_interfaces(${PROJECT_NAME}
                "srv/OledControl.srv"
                )

                ament_package()

                鱼哥,求助

                1 条回复 最后回复 回复 引用 0
                • 2
                  2996724802 年度VIP @小鱼
                  最后由 编辑

                  @小鱼 鱼哥哥,求助

                  1 条回复 最后回复 回复 引用 0
                  • 2
                    2996724802 年度VIP @小鱼
                    最后由 编辑

                    @小鱼 鱼哥,帮帮我

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

                      @2996724802 实在不行就跳过吧,这个网络环境是大问题,我后面基本都放弃本地构建了,直接用的github action 构建。

                      可以看看README https://github.com/micro-ROS/micro_ros_platformio?tab=readme-ov-file#requirements

                      安装下 apt install -y git cmake python3-pip 试试

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

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