2. 软件系统概述

2. 软件系统概述

2.1 基本启动模式

机器人工控机由MDU、HDU、ADU组成,均安装 Ubuntu 24.04 系统,使用 systemd 作为系统服务管理器,开机时会拉起 PM(进程启动管理)、SM(进程状态管理)模块,再由 PM 和 SM 配合拉起其余各个模块进程,SM 会对不同系统模式下的进程列表进行开启和关闭的状态管理。 PM 和 SM 的配置文件路径分别为 /agibot/software/v0/entry/launch/A3_ULTRA_DEFAULT.yaml(HDU & MDU & ADU,yaml名称根据机型变化) 和 agibot/software/v0/config/sm/sm_config.yaml(MDU),前者列有默认启动的进程列表,后者列有各个系统模式分别启用哪些功能组的进程 。

2.2 模块功能简介

模块性质所属工控机模块名称模块说明
管理模块MDUSM负责切换系统状态,管控进程列表
MDU & HDU&ADUPM 负责拉起进程,查询进程状态
公共服务MDU & HDU&ADUsetting提供基本机器人工控机设置,如 wifi、蓝牙等
recordbag用来持续记录bag包
ota_service软件更新工具
MDUgateway将外部的请求转发到内部各个模块
HDUdata_exporter提供日志批量、分时段导出等功能
功能模块HDUhal_audio音频硬件层
hal_hdu_camerahdu硬件相机层
hal_imu硬件Imu层
MDUhal_ethercat负责与HDU进行ethercat通信,传递硬件的状态信息和控制指令
hds健康管理模块
mc负责整个机器人的运动控制,下发运控动作指令
motion_player提供动作播放能力
skillpilot技能管理模块
tf坐标变换服务
ADUagivslamAGI 视觉 SLAM 定位模块
embodied_agent统一管理机器人交互能力
hal_depth_cameraHAL 层深度相机接口
hal_lidarHAL 层激光雷达接口
hal_siplHAL 层 NVIDIA SIPL 相机框架接口
legged_odometry足式里程计,提供腿部运动状态估计
mm地图管理模块
pnc规划与控制模块
slamSLAM 导航定位模块

2.2.1 系统模式

各个系统模式下激活和启动的模块有所不同,如下(摘录自 sm_config.yaml)

python
  # 系统状态
  system_modes:
    "Startup":
      next_mode_list: [ "Ready", "OTA", "Poweroff" ]
      active_FG_list: [ "System", "HAL", "EStop", "MoCap", "Gateway", "OTA" ]
      action_list:
        - [ DIFF ]
        - [ activate recordbag0 ]
        - [ activate recordbag1 ]

    "Poweroff":
      next_mode_list: []
      active_FG_list: []
      action_list:
        - [ open Poweroff ]

    "Reboot":
      next_mode_list: []
      active_FG_list: []
      action_list:
        - [ open Reboot ]

    # 系统的就绪状态,会启动业务管理模块以及HAL
    "Ready":
      next_mode_list: [ "Manual", "EStop", "Poweroff" ]
      active_FG_list: [ "System", "HAL", "EStop", "MoCap", "Gateway", "Motion", "OTA" ]
      action_list:
        - [ DIFF ]
        - [ activate recordbag0 ]
        - [ activate recordbag1 ]
        - [ activate agent ]
        - [ activate motion_player ]
      # post_process:
      #   - level: 34
      #     action_list: [ [ forbid Manual ] ]

    # OTA状态,会启动OTA功能组,完成OTA相关功能
    "OTA":
      next_mode_list: [ "Reboot", "Ready", "Poweroff" ]
      active_FG_list: [ "System", "HAL", "MoCap", "Gateway", "Motion", "OTA" ]
      action_list:
        - [ DIFF ]
        - [ activate recordbag0 ]
        - [ activate recordbag1 ]
        - [ deactivate agent ]
        - [ activate mc ]
        - [ deactivate motion_player ]

    # 手动状态,会启动遥控以及MC功能组
    "Manual":
      next_mode_list: [ "OTA", "Auto", "Reset", "EStop", "Poweroff", "MotionStream", "DataCollection", "FreeExploration", "Mapping", "Manipulator", "Lock" ]
      active_FG_list: [ "System", "HAL", "EStop", "MoCap", "Gateway", "Motion", "OTA" ]
      action_list:
        - [ DIFF ]
        - [ activate recordbag0 ]
        - [ activate recordbag1 ]
        - [ activate agent ]
        - [ activate mc ]
        - [ activate motion_player ]
      child_modes:
        - mode_name: "Safety"  # 通过tools下使能脚本调用进入的状态
          extra_next_modes: [ "OTA", "Reset" ]
          action_list:
            - [ close Motion ]
            - [ close EStop ]
      post_process:
        - level: 47
          action_list: [ [ fallback mc ] ]
    
    # 锁机状态
    "Lock":
      next_mode_list: [ "Manual" ]
      active_FG_list: [ "System", "HAL", "EStop", "MoCap", "Gateway", "Motion", "OTA" ]
      action_list:
        - [ DIFF ]
        - [ activate recordbag0 ]
        - [ activate recordbag1 ]
        - [ deactivate agent ]
        - [ activate mc ]
        - [ deactivate motion_player ]
      post_process:
        - level: 47
          action_list: [ [ fallback mc ] ]

    # 重置状态,用于恢复出厂设置
    "Reset":
      next_mode_list: [ "Reboot", "Poweroff" ]
      active_FG_list: [ "System", "OTA", "Gateway" ]
      action_list:
        - [ DIFF ]

    # 紧急停止状态,用于紧急停止
    "EStop":
      next_mode_list: [ "Ready", "OTA", "Poweroff" ]
      active_FG_list: [ "System", "HAL", "EStop", "MoCap", "Gateway", "Motion", "OTA" ]
      action_list:
        - [ DIFF ]
        - [ activate recordbag0 ]
        - [ activate recordbag1 ]
        - [ activate agent ]
        - [ deactivate mc ]
        - [ activate motion_player ]

    # 实时遥操作状态,用于实时遥操作
    "MotionStream":
      next_mode_list: [ "Manual", "EStop", "Poweroff", "DataCollection" ]
      active_FG_list: [ "System", "HAL", "EStop", "MoStream", "Gateway", "Motion", "OTA" ]
      action_list:
        - [ DIFF ]
        - [ activate recordbag0 ]
        - [ activate recordbag1 ]
        - [ activate agent ]
        - [ activate mc ]

  decision: # 系统决策层
    Auto_transToReady: true  # 如果为false需要在一定时机下调用一键激活脚本
    Auto_transToManual: true
    type: 1

2.2.2 模块禁用方式(谨慎)

如需二开替换某些功能模块,需要在系统中配置禁用该模块。

模块依照受 A3_ULTRA_DEFAULT.yaml 和 sm_config.yaml 管理分为两种,前者管理的模块会在启动时默认启动,后续也不受 sm 管理,保持常驻;后者管理的模块会在各个系统模式间切换。

  1. 如果需要禁用 A3_ULTRA_DEFAULT.yaml 中管理的模块(即其中 default_apps 中的部分),只需要从 default_apps 中移除即可。
  2. 如果需要禁用 sm 管理的模块,则需在相应的系统模式中加入一行 deactivate,指定去使能对应模块。
  3. 操作前请先备份相应目录下的A3_ULTRA_DEFAULT.yaml 和sm_config.yaml

以禁用 motion_player 模块为例,可按照如下步骤进行操作: 首先备份A3_ULTRA_DEFAULT.yaml(MDU)和 sm_config.yaml.

bash
cp /agibot/software/v0/entry/launch/A3_ULTRA_DEFAULT.yaml \
   /agibot/software/v0/entry/launch/A3_ULTRA_DEFAULT_backup.yaml

cp /agibot/software/v0/config/sm/sm_config.yaml \
   agibot/software/v0/config/sm/sm_config_backup.yaml

在 A3_ULTRA_DEFAULT.yaml(MDU) 将 default_apps 列表里 motion_player 模块移除:

diff
@@ -22,7 +22,6 @@ process_manager:
      "health_monitor0",
      "recordbag0",
-      "motion_player",
      "hds",
      "setting0",
      "mc",
      # "pnc",
      # "uwb_fusion",
      "hal_ethercat",
      "hal_elink",
      "skillpilot",
      "ota_master",
      "gateway",
      "ota_service0",

然后在 sm_config.yaml (MDU) 中 移除 SystemManagerModule 中 group 里的 motion_player, 将 MoCap 配置修改为空,并移除各状态下对 motion_player 的 activate / deactivate 操作:

diff
@@ -14,7 +14,7 @@ SystemManagerModule:
-      group: [motion_player, mc, hal_ethercat, poweroff0, reboot0, setting0, recordbag0, health_monitor0, hds, gateway, ota_master, ota_service0]
+      group: [mc, hal_ethercat, poweroff0, reboot0, setting0, recordbag0, health_monitor0, hds, gateway, ota_master, ota_service0]
diff
@@ -36,7 +36,7 @@ SystemManagerModule:
     "RC":
       [ "rc" ]
     "MoCap":
-      [ "motion_player" ]
+      []
     "MoStream":
       [ "motion_streamer" ]
diff
@@ -78,7 +78,6 @@ SystemManagerModule:
    "Ready":
      next_mode_list: [ "Manual", "EStop", "Poweroff" ]
      active_FG_list: [ "System", "HAL", "EStop", "MoCap", "Gateway", "Motion", "OTA" ]
      action_list:
        - [ DIFF ]
        - [ activate recordbag0 ]
        - [ activate recordbag1 ]
-        - [ activate motion_player ]
@@ -93,7 +93,6 @@ SystemManagerModule:
    "OTA":
      next_mode_list: [ "Reboot", "Ready", "Poweroff" ]
      active_FG_list: [ "System", "HAL", "MoCap", "Gateway", "Motion", "OTA" ]
      action_list:
        - [ DIFF ]
        - [ activate recordbag0 ]
        - [ activate recordbag1 ]
        - [ deactivate agent ]
        - [ activate mc ]
-        - [ deactivate motion_player]
@@ -105,7 +105,6 @@ SystemManagerModule:
    "Manual":
      next_mode_list: [ "OTA", "Auto", "Reset", "EStop", "Poweroff", "MotionStream", "DataCollection", "FreeExploration", "Mapping", "Manipulator", "Lock" ]
      active_FG_list: [ "System", "HAL", "EStop", "MoCap", "Gateway", "Motion", "OTA" ]
      action_list:
        - [ DIFF ]
        - [ activate recordbag0 ]
        - [ activate recordbag1 ]
        - [ activate agent ]
        - [ activate mc ]
-        - [ activate motion_player ]
@@ -126,7 +126,6 @@ SystemManagerModule:
    "Lock":
      next_mode_list: [ "Manual" ]
      active_FG_list: [ "System", "HAL", "EStop", "MoCap", "Gateway", "Motion", "OTA" ]
      action_list:
        - [ DIFF ]
        - [ activate recordbag0 ]
        - [ activate recordbag1 ]
        - [ deactivate agent ]
        - [ activate mc ]
-        - [ deactivate motion_player ]
@@ -148,7 +148,6 @@ SystemManagerModule:
    "EStop":
      next_mode_list: [ "Ready", "OTA", "Poweroff" ]
      active_FG_list: [ "System", "HAL", "EStop", "MoCap", "Gateway", "Motion", "OTA" ]
      action_list:
        - [ DIFF ]
        - [ activate recordbag0 ]
        - [ activate recordbag1 ]
        - [ activate agent ]
        - [ deactivate mc ]
-        - [ activate motion_player ]