跑跑啦航模

paopaola2025-3-31QGroundControl地面站4636

  任务指挥树​QGC创建用于从json元数据的层次结构动态编辑特定任务项命令的用户界面。此层次结构称为任务命令树。这样,在添加新命令时,只能创建json元数据。

  为什么是一棵树?​需要该树来处理不同地支持命令的区分固件和/或以不同方式支持命令的不同车辆类型的特征。最简单的例子是mavlink spec可能包括不是所有固件都支持的命令参数。或仅对某些车辆类型有效的命令参数。此外,在某些情况下,GCS可能决定向最终用户隐藏某些命令参数,因为它们太复杂或导致可用性问题。

  该树是MissionCommandTree类:MissionCommandTree.cc,MissionCommandTree.h

  树根​树的根是json元数据,它与mavlink规范完全匹配。

  在这里你可以看到根的例子json用于MAV_CMD_NAV_WAYPOINT:

  {

  "id": 16,

  "rawName": "MAV_CMD_NAV_WAYPOINT",

  "friendlyName": "Waypoint",

  "description": "Travel to a position in 3D space.",

  "specifiesCoordinate": true,

  "friendlyEdit": true,

  "category": "Basic",

  "param1": {

  "label": "Hold",

  "units": "secs",

  "default": 0,

  "decimalPlaces": 0

  },

  "param2": {

  "label": "Acceptance",

  "units": "m",

  "default": 3,

  "decimalPlaces": 2

  },

  "param3": {

  "label": "PassThru",

  "units": "m",

  "default": 0,

  "decimalPlaces": 2

  },

  "param4": {

  "label": "Yaw",

  "units": "deg",

  "nanUnchanged": true,

  "default": null,

  "decimalPlaces": 2

  }

  },

  注意: 实际上,基于此的信息应由mavlink本身提供,不需要成为GCS的一部分。

  叶节点​叶节点然后向用户提供可以覆盖命令的值和/或从显示中移除参数的元数据。完整的树层次结构是这样的:

  根通用Mavlink

  特定车辆类型-通用规范的特定车辆覆盖

  特定固件类型-每个固件类型 (PX4/ArduPilot) 一个可选叶节点

  特定车辆类型-每个车辆类型 (FW/MR/VTOL/Rover/Sub) 一个可选叶节点

  注意: 实际上,此超驰功能应该是mavlink规范的一部分,并且应该能够从车辆中查询。

  从完整树构建实例树​由于json元数据提供了所有固件/车辆类型组合的信息,因此必须基于用于创建计划的固件和车辆类型来构建要使用的实际树。这是通过过程调用 "折叠" 完整的树到固件/车辆特定的树 (代码)。

  步骤如下:

  将根添加到实例树

  将车辆类型特定的替代应用于实例树

  将特定于固件类型的覆盖应用于实例树

  将特定于固件/车辆类型的覆盖应用于实例树

  然后使用生成的任务命令树为计划视图项目编辑器构建UI。实际上,它不仅用于此目的,还有许多其他地方可以了解有关特定命令id的更多信息。

  示例层次结构MAV_CMD_NAV_WAYPOINT​让我们来看看一个示例层次结构MAV_CMD_NAV_WAYPOINT。上面显示了根信息。

  根-车辆类型特定的叶节点​hiearchy的下一个级别是通用mavlink,但特定于车辆。Json文件在这里:先生,前,漫游者,Sub,垂直起降。这里是 (固定翼) 的覆盖范围 (https://github.com/mavlink/qgroundcontrol/blob/master/src/MissionManager/MavCmdInfoFixedWing.json# L7):

  {

  "id": 16,

  "comment": "MAV_CMD_NAV_WAYPOINT",

  "paramRemove": "4"

  },

  这样做是删除param4的编辑UI,它是偏航的,不被固定翼使用。由于这是根的叶节点,因此无论固件类型如何,这都适用于所有固定翼飞行器。

  根-固件类型特定的叶节点​hiearchy的下一级是特定于固件类型但适用于所有车辆类型的覆盖。再次让lookok在航路点覆盖:

  ArduPilot:

  {

  "id": 16,

  "comment": "MAV_CMD_NAV_WAYPOINT",

  "paramRemove": "2"

  },

  PX4:

  {

  "id": 16,

  "comment": "MAV_CMD_NAV_WAYPOINT",

  "paramRemove": "2,3"

  },

  您可以看到,对于这两个固件,param2是接受半径从编辑ui中删除。这是QGC的具体决定。通常,使用firmwares通用接受半径处理比指定值更安全,更容易。所以我们决定对用户隐藏它。

  您还可以看到,对于PX4 param3/PassThru被删除,因为它不被PX支持。

  根-固件类型特定-车辆类型特定叶节点​hiearchy的最后一级是固件和车辆类型特定的。

  ArduPilot/MR:

  {

  "id": 16,

  "comment": "MAV_CMD_NAV_WAYPOINT",

  "paramRemove": "2,3,4"

  },

  在这里,您可以看到,对于ArduPilot多旋翼飞行器,param2/3/4接受/通过/偏航被移除。例如,删除了Yaw,因为它不受支持。由于此代码的工作方式的怪癖,您需要从较低级别重复覆盖。

  任务命令UI信息​两个类定义与命令关联的元数据:

  MissionCommandUIInfo-整个命令的元数据

  MissionCmdParamInfo-命令中参数的元数据

  源注释了支持的json密钥的完整详细信息。

  MissionCommandUIInfo:

  /// UI Information associated with a mission command (MAV_CMD)

  ///

  /// MissionCommandUIInfo is used to automatically generate editing ui for a MAV_CMD. This object also supports the concept of only having a set of partial

  /// information for the command. This is used to create overrides of the base command information. For on override just specify the keys you want to modify

  /// from the base command ui info. To override param ui info you must specify the entire MissionParamInfo object.

  ///

  /// The json format for a MissionCommandUIInfo object is:

  ///

  /// Key Type Default Description

  /// id int reauired MAV_CMD id

  /// comment string Used to add a comment

  /// rawName string required MAV_CMD enum name, should only be set of base tree information

  /// friendlyName string rawName Short description of command

  /// description string Long description of command

  /// specifiesCoordinate bool false true: Command specifies a lat/lon/alt coordinate

  /// specifiesAltitudeOnly bool false true: Command specifies an altitude only (no coordinate)

  /// standaloneCoordinate bool false true: Vehicle does not fly through coordinate associated with command (exampl: ROI)

  /// isLandCommand bool false true: Command specifies a land command (LAND, VTOL_LAND, ...)

  /// friendlyEdit bool false true: Command supports friendly editing dialog, false: Command supports 'Show all values" style editing only

  /// category string Advanced Category which this command belongs to

  /// paramRemove string Used by an override to remove params, example: "1,3" will remove params 1 and 3 on the override

  /// param[1-7] object MissionCommandParamInfo object

  ///

  MissionCmdParamInfo:

  /// UI Information associated with a mission command (MAV_CMD) parameter

  ///

  /// MissionCommandParamInfo is used to automatically generate editing ui for a parameter associated with a MAV_CMD.

  ///

  /// The json format for a MissionCmdParamInfo object is:

  ///

  /// Key Type Default Description

  /// label string required Label for text field

  /// units string Units for value, should use FactMetaData units strings in order to get automatic translation

  /// default double 0.0/NaN Default value for param. If no default value specified and nanUnchanged == true, then defaultValue is NaN.

  /// decimalPlaces int 7 Number of decimal places to show for value

  /// enumStrings string Strings to show in combo box for selection

  /// enumValues string Values associated with each enum string

  /// nanUnchanged bool false True: value can be set to NaN to signal unchanged

  在GitHub上编辑

跑跑啦航模淘宝直销

qq群号241350086 微信号paopaola_com qq群号928697906
长距离FPV无人机,高清数字图传,终身保修和升级服务。