ATT_POWER 7e4b5460c2
feat: add a new plugin: echo (#51)
* CI: change build worlflow image tag from v20240927 to latest

* feat/plugins: Add echo plugin

- Add echo plugin for message pass-through and logging
- Implement loading and management of different types of support packages
- Add support for multi-threaded executors
- Optimize log initialization and management logic
- Add support for YAML configuration files

* build: Update build scripts and enable Echo plugin

- Add build options for Echo plugin in build.bat, build.sh, test.bat, and test.sh scripts
- Optimize JSON serialization error handling and log output in echo_plugin.cc

* chore: Add Echo plugin related documentation

- Update release notes with Echo plugin feature description
- Add Echo plugin usage documentation
- Add Echo plugin example configuration and running instructions

* chore: format the code
- Add thread safety checks for Echo executor
- Optimize code structure to improve readability and maintainability

* choro: restructure JSON parsing logic

- Replace json-c with jsoncpp library
- Rewrite json_to_yaml function to improve code readability and robustness

* choro: adapt CMakeLists for Windows compatibility

* choro : turn off the echo plugin in windows

* feat(echo_plugin): Support YAML format message echo

- Modify GetYamlCpp.cmake to enable yaml-cpp installation
- Add yaml_convert.h and yaml_convert_test.cc in ros2_util
- Update echo_plugin to support YAML format message serialization and deserialization
- Add YAML serialization type support in aimrt_module_ros2_interface

* choro: Fix documentation

* choro : fix format and delete the extra support for echo about pb message type

* choro : format

* choro: add ros2 example for echo plugin and delete useless code

* choro: rename the echo example shell

* choro: fix some mistake

* chore: refactor type support package loader and migrate to core module

- Migrate TypeSupportPkgLoader from echo_plugin and record_playback_plugin to core/util directory
- Optimize log output, replace printf with AIMRT_INFO

* choro: replace the aimrt::common::util::AimRTException() to AIMRT_ASSERT

---------

Co-authored-by: yuguanlin <yuguanlin@agibot.com>
2024-10-31 20:03:42 +08:00

2.8 KiB
Raw Blame History

echo插件

相关链接

参考示例:

插件概述

echo_plugin用于对 Channel 中的消息进行回显,插件支持独立的 type_support_pkg并支持指定执行器。

插件的配置项如下:

节点 类型 是否可选 默认值 作用
type_support_pkgs array 必选 [] type support 包配置
type_support_pkgs[i].path string 必选 "" type support 包的路径
executor string 可选 "" 回显使用的执行器,要求必须是线程安全
topic_meta_list array 必选 [] 要回显的 topic 和类型
topic_meta_list[j].topic_name string 必选 "" 要回显的 topic
topic_meta_list[j].msg_type string 必选 "" 要回显的消息类型
topic_meta_list[j].echo_type string 可选 "json" 回显消息的格式ros2 支持 "json", "yaml" pb 只支持 "json"

回显消息的简单示例配置

回显消息的存在两种配置,分别是 是否指定执行器 和 回显消息的格式:

  • 是否指定执行器: 插件会使用指定的执行器来处理回显消息,如果未指定执行器,则使用默认的执行器;
  • 回显消息的格式: ros2 消息类型 支持 "json", "yaml" pb只支持 "json"

以下是一个带执行器的回显消息格式为 json 的简单示例配置:

aimrt:
  plugin:
    plugins:
      - name: echo_plugin
        path: ./libaimrt_echo_plugin.so
        options:
          type_support_pkgs:
            - path: ./libexample_event_ts_pkg.so       
          executor: echo_executor
          topic_meta_list:
            - topic_name: test_topic
              msg_type: pb:aimrt.protocols.example.ExampleEventMsg                
              echo_type: json
  executor:
    executors:
      - name: echo_executor
        type: simple_thread
  channel:
    # ...

以下是一个不带执行器的回显消息格式为 json 的简单示例配置:

aimrt:
  plugin:
    plugins:
      - name: echo_plugin
        path: ./libaimrt_echo_plugin.so
        options:
          type_support_pkgs:
            - path: ./libexample_event_ts_pkg.so       
          topic_meta_list:
            - topic_name: test_topic
              msg_type: pb:aimrt.protocols.example.ExampleEventMsg       
              echo_type: json
  executor:
    executors:
      - name: echo_executor
        type: simple_thread
  channel:
    # ...