Skip to content

控制分配 (混控)

:::note 控制分配取代了在 PX4 v1.13 中使用的旧的混控方法。 PX4 v1.13 文档见: 混控& 驱动器, 构型文件添加一个新的机型配置。 :::

PX4从核心控制器获取所需的扭矩和推力指令,并将它们转换为控制电机或作动器的驱动指令。

指令间的转换取决于飞行器的物理构型。 例如,给“向右转”需要给出一个扭矩指令:

  • 对于每个副翼都有一个舵机的飞机来说,该指令将会控制一个舵机向高处偏转,另一个向低处偏转。
  • 多旋翼将会通过改变所有电机的转速来向右偏航。

PX4将这个转换逻辑区分开,这个逻辑被称为从姿态/角速率控制器输出的“混控”。 这样可以确保核心控制器不需要对每个机型构型进行特殊处理,可以大大提高复用性。

此外,PX4还将输出函数映射至指定的硬件输出。 这也意味着任何电机或舵机可以分配给几乎任何物理输出。

混控概览

作动器控制流程

模块和uORB话题混控流程概览(点击全屏查看):

Pipeline Overview

Notes:

  • 角速率控制器输出力矩和推力设定值
  • control_allocator 模块:
    • 根据配置参数处理不同飞行器构型
    • 进行混控计算
    • 处理电机失效
    • 发布电机和作动器控制信号
    • 单独发布舵机配平,以便在 测试驱动器 (使用测试滑块)时将它们添加为偏移。
  • 输出驱动:
    • 处理硬件初始化和更新
    • 使用共享库 src/libs/mixer_module。 驱动程序定义了参数前缀,例如 PWM_MAIN 被库用于配置。 其主要任务是从输入话题中选择,并根据用户设置的 <param_prefix>_FUNCx 参数值将正确的数据分配给输出。 例如, PWM_MAIN_FUNC3 已设置为 Motor 2,第三个输出设置为来自 actuator_motors的第二个电机。
    • 输出函数定义于 src/lib/mixer_module/output_functions.yaml
  • 如果想要通过MAVLink控制其输出,请将相关的输出函数设置为 Offboard Actor Set x,然后发送 MAV_CMD_DO_SET_ACTUATOR MAVLink指令。

添加新构型或输出函数

See this commit for how to add a new geometry. The QGC UI will then automatically show the right configuration UI when CA_AIRFRAME is set to the new geometry.

This commit shows how to add a new output function. Any uORB topic can be subscribed and assigned to a function.

Note that parameters for control allocation are defined in src/modules/control_allocator/module.yaml The schema for this file is here (in particular, search for the key mixer:

设置默认机型构型

When adding a new frame configuration, set the appropriate CA_AIRFRAME and other default mixer values for the geometry.

You can see this, for example, in the airframe configuration file 13200_generic_vtol_tailsitter

sh
...
param set-default CA_AIRFRAME 4
param set-default CA_ROTOR_COUNT 2
param set-default CA_ROTOR0_KM -0.05
param set-default CA_ROTOR0_PY 0.2
...

设置构型和输出

The broad geometry and default parameters for a vehicle are set (from the frame configuration file) when selecting the airframe in QGroundControl: Basic Configuration > Airframe.

The geometry parameters and output mapping for the specific frame and flight controller hardware are then configured using the QGroundControl Actuators setup screen: Basic Configuration > Actuator Configuration and Testing.