text: (window.webpackJsonp=window.webpackJsonp||[]).push([[1068],{2237:function(a,t,e){"use strict";e.r(t);var s=e(18),n=Object(s.a)({},(function(){var a=this,t=a.$createElement,e=a._self._c||t;return e("ContentSlotsDistributor",{attrs:{"slot-key":a.$parent.slotKey}},[e("h1",{attrs:{id:"参数设置"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#参数设置"}},[a._v("#")]),a._v(" 参数设置")]),a._v(" "),e("p",[a._v("PX4 使用 *param subsystem *（"),e("code",[a._v("float")]),a._v(" 和 "),e("code",[a._v("int32_t")]),a._v(" 值的平面表）和文本文件（用于混频器和启动脚本）来存储其配置。")]),a._v(" "),e("p",[a._v("本节详细讨论 "),e("em",[a._v("param")]),a._v(" 子系统。 This section discusses the "),e("em",[a._v("param")]),a._v(" subsystem in detail. It covers how to list, save and load parameters, and how to define them.")]),a._v(" "),e("div",{staticClass:"custom-block tip"},[e("p",{staticClass:"custom-block-title"},[a._v("提示")]),a._v(" "),e("p",[e("RouterLink",{attrs:{to:"/zh/concept/system_startup.html"}},[a._v("System startup")]),a._v(" and the way that "),e("RouterLink",{attrs:{to:"/zh/dev_airframes/adding_a_new_frame.html"}},[a._v("airframe configurations")]),a._v(" work are detailed on other pages.")],1)]),a._v(" "),e("h2",{attrs:{id:"命令行使用方法"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#命令行使用方法"}},[a._v("#")]),a._v(" 命令行使用方法")]),a._v(" "),e("p",[e("code",[a._v("param show")]),a._v(" 命令列出了所有系统参数:")]),a._v(" "),e("h3",{attrs:{id:"获取和设置参数"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#获取和设置参数"}},[a._v("#")]),a._v(" 获取和设置参数")]),a._v(" "),e("p",[a._v('为了更有选择性，可以使用带有通配符 "*" 的部分参数名称：')]),a._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[a._v("param show\n")])])]),e("p",[a._v("可以使用 "),e("code",[a._v("-c")]),a._v(" 标志显示已更改的所有参数（从其默认值）：")]),a._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[a._v("nsh"),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v(">")]),a._v(" param show RC_MAP_A*\nSymbols: x "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("=")]),a._v(" used, + "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("=")]),a._v(" saved, * "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("=")]),a._v(" unsaved\nx   RC_MAP_AUX1 "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("[")]),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("359,498")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("]")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token builtin class-name"}},[a._v(":")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("0")]),a._v("\nx   RC_MAP_AUX2 "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("[")]),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("360,499")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("]")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token builtin class-name"}},[a._v(":")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("0")]),a._v("\nx   RC_MAP_AUX3 "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("[")]),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("361,500")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("]")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token builtin class-name"}},[a._v(":")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("0")]),a._v("\nx   RC_MAP_ACRO_SW "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("[")]),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("375,514")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("]")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token builtin class-name"}},[a._v(":")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("0")]),a._v("\n\n "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("723")]),a._v(" parameters total, "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("532")]),a._v(" used.\n")])])]),e("p",[a._v("You can save any parameters that have been "),e("em",[a._v("touched")]),a._v(" since all parameters were last reset to their firmware-defined defaults (this includes any parameters that have changed been changed, even if they have been changed back to their default).")]),a._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[a._v("param show -c\n")])])]),e("p",[a._v("Synchronization is important because a parameter can be changed to another value at any time. Your code should "),e("em",[a._v("always")]),a._v(" use the current value from the parameter store. If getting the latest version is not possible, then a reboot will be required after the parameter is changed (set this requirement using the "),e("code",[a._v("@reboot_required")]),a._v(" metadata).")]),a._v(" "),e("h3",{attrs:{id:"导出和加载参数"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#导出和加载参数"}},[a._v("#")]),a._v(" 导出和加载参数")]),a._v(" "),e("p",[a._v("标准的 "),e("code",[a._v("param save")]),a._v(" 命令将参数存储在当前默认文件中:")]),a._v(" "),e("p",[a._v("如果提供了参数，它将将参数存储到这个新位置:")]),a._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[a._v("param save\n")])])]),e("p",[a._v("有两个不同的命令可用于 "),e("em",[a._v("load")]),a._v(" 参数:")]),a._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[a._v("param save /fs/microsd/vtol_param_backup\n")])])]),e("p",[e("code",[a._v("load")]),a._v(' 有效地将参数重置为保存参数时的状态（我们说 "有效"，因为保存在文件中的任何参数都将被更新，但其他参数可能具有与参数文件）。')]),a._v(" "),e("ul",[e("li",[e("code",[a._v("param load")]),a._v(" 首先将所有参数完全重置为默认值，然后用存储在文件中的任何值覆盖参数值。")]),a._v(" "),e("li",[e("code",[a._v("param import")]),a._v(" 只是用文件中的值覆盖参数值，然后保存结果（即有效调用 `param save</0 >）。")])]),a._v(" "),e("p",{attrs:{"spaces-before":"0"}},[a._v("The "),e("code",[a._v('load` effectively resets the parameters to the state when the parameters were saved (we say "effectively" because any parameters saved in the file will be updated, but other parameters may have different firmware-defined default values than when the parameters file was created). ')])]),a._v(" "),e("p",[a._v("By contrast, "),e("code",[a._v("import")]),a._v(" merges the parameters in the file with the current state of the vehicle. This can be used, for example, to just import a parameter file containing calibration data, without overwriting the rest of the system configuration.")]),a._v(" "),e("p",[a._v("参数名称不得超过 16个 ASCII 字符。")]),a._v(" "),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[e("span",{pre:!0,attrs:{class:"token comment"}},[a._v("# 将参数重置为保存文件时,")]),a._v("\nparam load /fs/microsd/vtol_param_backup\n"),e("span",{pre:!0,attrs:{class:"token comment"}},[a._v("# 保存参数 (不自动完成与负载)")]),a._v("\nparam save\n")])])]),e("div",{staticClass:"language-sh extra-class"},[e("pre",{pre:!0,attrs:{class:"language-sh"}},[e("code",[e("span",{pre:!0,attrs:{class:"token comment"}},[a._v("# 将保存的参数与当前参数合并")]),a._v("\nparam "),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("import")]),a._v(" /fs/microsd/vtol_param_backup  \n")])])]),e("h2",{attrs:{id:"参数名称"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#参数名称"}},[a._v("#")]),a._v(" 参数名称")]),a._v(" "),e("p",[a._v("Parameter names must be no more than 16 ASCII characters.")]),a._v(" "),e("p",[a._v("By convention, every parameter in a group should share the same (meaningful) string prefix followed by an underscore, and "),e("code",[a._v("MC_")]),a._v(" and "),e("code",[a._v("FW_")]),a._v(" are used for parameters related specifically to Multicopter or Fixed wing systems. This convention is not enforced.")]),a._v(" "),e("p",[a._v("有单独的 C 和 C++ 的 API 可用于从 PX4 模块和驱动程序中访问参数值。")]),a._v(" "),e("h2",{attrs:{id:"c-c-api"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#c-c-api"}},[a._v("#")]),a._v(" C / C++ API")]),a._v(" "),e("p",[a._v("API 之间的一个重要区别是，C++ 版本具有更有效的标准化机制，可与参数值的更改（即来自 GCS 的更改）同步。")]),a._v(" "),e("p",[a._v("One important difference between the APIs is that the C++ version has a more efficient standardized mechanism to synchronize with changes to parameter values (i.e. from a GCS).")]),a._v(" "),e("p",[a._v("此外，C++ 版本在 RAM 方面也具有更好的类型安全性和更少的开销。 In addition, the C++ version has also better type-safety and less overhead in terms of RAM. The drawback is that the parameter name must be known at compile-time, while the C API can take a dynamically created name as a string. If getting the latest version is not possible, then a reboot will be required after the parameter is changed (set this requirement using the "),e("code",[a._v("@reboot_required")]),a._v(" metadata).")]),a._v(" "),e("p",[a._v("The C++ API provides macros to declare parameters as "),e("em",[a._v("class attributes")]),a._v('. You add some "boilerplate" code to regularly listen for changes in the '),e("RouterLink",{attrs:{to:"/zh/middleware/uorb.html"}},[a._v("uORB Topic")]),a._v(" associated with "),e("em",[a._v("any")]),a._v(' parameter update. Framework code then (invisibly) handles tracking uORB messages that affect your parameter attributes and keeping them in sync. In the rest of the code you can just use the defined parameter attributes and they will always be up to date! 您可以添加一些 "样板" 代码，以定期侦听与 '),e("em",[a._v("any")]),a._v(" 参数更新相关的 "),e("RouterLink",{attrs:{to:"/zh/middleware/uorb.html"}},[a._v("uORB topic")]),a._v(" 中的更改。")],1),a._v(" "),e("h3",{attrs:{id:"c-api"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#c-api"}},[a._v("#")]),a._v(" C++ API")]),a._v(" "),e("p",[a._v("The C++ API provides macros to declare parameters as "),e("em",[a._v("class attributes")]),a._v('. You add some "boilerplate" code to regularly listen for changes in the '),e("RouterLink",{attrs:{to:"/zh/middleware/uorb.html"}},[a._v("uORB Topic")]),a._v(" associated with "),e("em",[a._v("any")]),a._v(" parameter update. Framework code then (invisibly) handles tracking uORB messages that affect your parameter attributes and keeping them in sync. In the rest of the code you can just use the defined parameter attributes and they will always be up to date!")],1),a._v(" "),e("p",[a._v("First include "),e("strong",[a._v("px4_platform_common/module_params.h")]),a._v(" in the class header for your module or driver (to get the "),e("code",[a._v("DEFINE_PARAMETERS")]),a._v(" macro):")]),a._v(" "),e("div",{staticClass:"language-cpp extra-class"},[e("pre",{pre:!0,attrs:{class:"language-cpp"}},[e("code",[e("span",{pre:!0,attrs:{class:"token macro property"}},[e("span",{pre:!0,attrs:{class:"token directive-hash"}},[a._v("#")]),e("span",{pre:!0,attrs:{class:"token directive keyword"}},[a._v("include")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[a._v("<px4_module_params.h>")])]),a._v("\n")])])]),e("p",[a._v("Derive your class from "),e("code",[a._v("ModuleParams")]),a._v(", and use "),e("code",[a._v("DEFINE_PARAMETERS")]),a._v(" to specify a list of parameters and their associated parameter attributes. The names of the parameters must be the same as their parameter metadata definitions.")]),a._v(" "),e("div",{staticClass:"language-cpp extra-class"},[e("pre",{pre:!0,attrs:{class:"language-cpp"}},[e("code",[e("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("class")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token class-name"}},[a._v("MyModule")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v(":")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token base-clause"}},[e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(".")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(".")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(".")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(",")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("public")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token class-name"}},[a._v("ModuleParams")])]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("{")]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("public")]),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v(":")]),a._v("\n    "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(".")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(".")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(".")]),a._v("\n\n"),e("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("private")]),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v(":")]),a._v("\n\n    "),e("span",{pre:!0,attrs:{class:"token comment"}},[a._v("/**\n     * Check for parameter changes and update them if needed.\n     class MyModule : ..., public ModuleParams\n{\npublic:\n    ...\n\nprivate:\n\n    /**\n     * Check for parameter changes and update them if needed.\n     * @param parameter_update_sub uorb subscription to parameter_update\n     */")]),a._v("\n    "),e("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("void")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("parameters_update")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),e("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("int")]),a._v(" parameter_update_sub"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(",")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("bool")]),a._v(" force "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("=")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token boolean"}},[a._v("false")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n\n    "),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("DEFINE_PARAMETERS")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("\n        "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("ParamInt"),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("<")]),a._v("px4"),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("::")]),a._v("params"),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("::")]),a._v("SYS_AUTOSTART"),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v(">")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),a._v(" _sys_autostart"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(",")]),a._v("   "),e("span",{pre:!0,attrs:{class:"token comment"}},[a._v("/**< example parameter */")]),a._v("\n        "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("ParamFloat"),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("<")]),a._v("px4"),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("::")]),a._v("params"),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("::")]),a._v("ATT_BIAS_MAX"),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v(">")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),a._v(" _att_bias_max  "),e("span",{pre:!0,attrs:{class:"token comment"}},[a._v("/**< another parameter */")]),a._v("\n    "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("}")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n")])])]),e("p",[a._v("首先包括访问 uORB parameter_update 消息的标头:")]),a._v(" "),e("p",[a._v("First include the header to access the uORB parameter_update message:")]),a._v(" "),e("div",{staticClass:"language-cpp extra-class"},[e("pre",{pre:!0,attrs:{class:"language-cpp"}},[e("code",[e("span",{pre:!0,attrs:{class:"token macro property"}},[e("span",{pre:!0,attrs:{class:"token directive-hash"}},[a._v("#")]),e("span",{pre:!0,attrs:{class:"token directive keyword"}},[a._v("include")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[a._v("<uORB/topics/parameter_update.h>")])]),a._v("\n")])])]),e("p",[a._v("Subscribe to the update message when the module/driver starts and un-subscribe when it is stopped. "),e("code",[a._v("parameter_update_sub")]),a._v(" returned by "),e("code",[a._v("orb_subscribe()")]),a._v(" is a handle we can use to refer to this particular subscription.")]),a._v(" "),e("div",{staticClass:"language-cpp extra-class"},[e("pre",{pre:!0,attrs:{class:"language-cpp"}},[e("code",[e("span",{pre:!0,attrs:{class:"token macro property"}},[e("span",{pre:!0,attrs:{class:"token directive-hash"}},[a._v("#")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token expression"}},[a._v("Subscribe to parameter_update message")])]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("int")]),a._v(" parameter_update_sub "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("=")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("orb_subscribe")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("ORB_ID")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("parameter_update"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(".")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(".")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(".")]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token macro property"}},[e("span",{pre:!0,attrs:{class:"token directive-hash"}},[a._v("#")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token expression"}},[a._v("Unsubscribe to parameter_update messages")])]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("orb_unsubscribe")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("parameter_update_sub"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token macro property"}},[e("span",{pre:!0,attrs:{class:"token directive-hash"}},[a._v("#")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token expression"}},[a._v("Unsubscribe to parameter_update messages")])]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("orb_unsubscribe")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("parameter_update_sub"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n")])])]),e("p",[a._v("在上面的方法中：")]),a._v(" "),e("div",{staticClass:"language-cpp extra-class"},[e("pre",{pre:!0,attrs:{class:"language-cpp"}},[e("code",[e("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("void")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token class-name"}},[a._v("Module")]),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("::")]),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("parameters_update")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),e("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("int")]),a._v(" parameter_update_sub"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(",")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("bool")]),a._v(" force"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("{")]),a._v("\n    "),e("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("bool")]),a._v(" updated"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n    "),e("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("struct")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token class-name"}},[a._v("parameter_update_s")]),a._v(" param_upd"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n\n    "),e("span",{pre:!0,attrs:{class:"token comment"}},[a._v("// Check if any parameter updated")]),a._v("\n    "),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("orb_check")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("parameter_update_sub"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(",")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("&")]),a._v("updated"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n\n    "),e("span",{pre:!0,attrs:{class:"token comment"}},[a._v("// If any parameter updated copy it to: param_upd")]),a._v("\n    "),e("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("if")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("updated"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("{")]),a._v("\n        "),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("orb_copy")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("ORB_ID")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("parameter_update"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(",")]),a._v(" parameter_update_sub"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(",")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("&")]),a._v("param_upd"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n    "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("}")]),a._v("\n\n    "),e("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("if")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("force "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("||")]),a._v(" updated"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("{")]),a._v("\n        "),e("span",{pre:!0,attrs:{class:"token comment"}},[a._v("// If any parameter updated, call updateParams() to check if")]),a._v("\n        "),e("span",{pre:!0,attrs:{class:"token comment"}},[a._v("// this class attributes need updating (and do so). ")]),a._v("\n        "),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("updateParams")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n    "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("}")]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("}")]),a._v(" \n        "),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("updateParams")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n    "),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("}")]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("}")]),a._v("\n")])])]),e("p",[a._v("然后，参数属性 ("),e("code",[a._v("_sys_autostart")]),a._v(" 和 "),e("code",[a._v("_att_bias_max")]),a._v(" 在本例中) 可用于表示参数，并将在参数值更改时进行更新。")]),a._v(" "),e("ul",[e("li",[e("code",[a._v("orb_check()")]),a._v(" 告诉我们是否有 "),e("em",[a._v("任何")]),a._v(" 更新 "),e("code",[a._v("param_update")]),a._v(" 的 uorb 消息 (但不是受影响的参数)，并设置 "),e("code",[a._v("updated")]),a._v(" bool。")]),a._v(" "),e("li",[a._v('如果更新了 "某些" 参数，我们会将更新复制到 '),e("code",[a._v("parameter_update_s")]),a._v(" ("),e("code",[a._v("param_upd")]),a._v(")")]),a._v(" "),e("li",[a._v("调用 "),e("code",[a._v("ModuleParams::updateParams()")]),a._v("。 Then we call "),e("code",[a._v("ModuleParams::updateParams()")]),a._v('. This "under the hood" checks if the specific parameter attributes listed in our '),e("code",[a._v("DEFINE_PARAMETERS")]),a._v(" list need updating, and then does so if needed.")]),a._v(" "),e("li",[a._v("This example doesn't call "),e("code",[a._v("Module::parameters_update()")]),a._v(" with "),e("code",[a._v("force=True")]),a._v(". If you had other values that needed to be set up a common pattern is to include them in the function, and call it once with "),e("code",[a._v("force=True")]),a._v(" during initialisation. 如果您有其他需要设置公共模式的值，则是将它们包含在函数中，并在初始化过程中使用 "),e("code",[a._v("force=True")]),a._v(" 调用它一次。")])]),a._v(" "),e("p",[a._v("C API 可以在模块和驱动程序中使用。")]),a._v(" "),e("div",{staticClass:"custom-block tip"},[e("p",{staticClass:"custom-block-title"},[a._v("提示")]),a._v(" "),e("p",[a._v("The "),e("RouterLink",{attrs:{to:"/zh/modules/module_template.html"}},[a._v("Application/Module Template")]),a._v(" uses the new-style C++ API but does not include "),e("a",{attrs:{href:"#parameter-metadata"}},[a._v("parameter metadata")]),a._v(".")],1)]),a._v(" "),e("h3",{attrs:{id:"c-api-2"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#c-api-2"}},[a._v("#")]),a._v(" C API")]),a._v(" "),e("p",[a._v("The C API can be used within both modules and drivers.")]),a._v(" "),e("p",[a._v("First include the parameter API:")]),a._v(" "),e("div",{staticClass:"language-C extra-class"},[e("pre",{pre:!0,attrs:{class:"language-c"}},[e("code",[e("span",{pre:!0,attrs:{class:"token macro property"}},[e("span",{pre:!0,attrs:{class:"token directive-hash"}},[a._v("#")]),e("span",{pre:!0,attrs:{class:"token directive keyword"}},[a._v("include")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token string"}},[a._v("<parameters/param.h>")])]),a._v("\n")])])]),e("p",[a._v("Then retrieve the parameter and assign it to a variable (here "),e("code",[a._v("my_param")]),a._v("), as shown below for "),e("code",[a._v("PARAM_NAME")]),a._v(". The variable "),e("code",[a._v("my_param")]),a._v(" can then be used in your module code.")]),a._v(" "),e("div",{staticClass:"language-C extra-class"},[e("pre",{pre:!0,attrs:{class:"language-c"}},[e("code",[a._v("int32_t my_param "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("=")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("0")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("param_get")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("param_find")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),e("span",{pre:!0,attrs:{class:"token string"}},[a._v('"PARAM_NAME"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(",")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("&")]),a._v("my_param"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n")])])]),e("div",{staticClass:"custom-block note"},[e("p",{staticClass:"custom-block-title"},[a._v("注解")]),a._v(" "),e("p",[a._v("If "),e("code",[a._v("PARAM_NAME")]),a._v(" was declared in parameter metadata then its default value will be set, and the above call to find the parameter should always succeed. 通常，它与关联的模块一起存储。")]),a._v(" "),e("p",[e("code",[a._v("param_find()")]),a._v(' is an "expensive" operation, which returns a handle that can be used by '),e("code",[a._v("param_get()")]),a._v(". If you're going to read the parameter multiple times, you may cache the handle and use it in "),e("code",[a._v("param_get()")]),a._v(" when needed")]),a._v(" "),e("div",{staticClass:"language-cpp extra-class"},[e("pre",{pre:!0,attrs:{class:"language-cpp"}},[e("code",[e("span",{pre:!0,attrs:{class:"token macro property"}},[e("span",{pre:!0,attrs:{class:"token directive-hash"}},[a._v("#")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token expression"}},[a._v("Get the handle to the parameter")])]),a._v("\nparam_t my_param_handle "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("=")]),a._v(" PARAM_INVALID"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\nmy_param_handle "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("=")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("param_find")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),e("span",{pre:!0,attrs:{class:"token string"}},[a._v('"PARAM_NAME"')]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n\n"),e("span",{pre:!0,attrs:{class:"token macro property"}},[e("span",{pre:!0,attrs:{class:"token directive-hash"}},[a._v("#")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token expression"}},[a._v("Query the value of the parameter when needed")])]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token keyword"}},[a._v("int32_t")]),a._v(" my_param "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("=")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("0")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("param_get")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("my_param_handle"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(",")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("&")]),a._v("my_param"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n")])])]),e("h2",{attrs:{id:"参数元数据"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#参数元数据"}},[a._v("#")]),a._v(" 参数元数据")]),a._v(" "),e("p",[a._v("PX4 uses an extensive parameter metadata system to drive the user-facing presentation of parameters, and to set the default value for each parameter in firmware.")]),a._v(" "),e("div",{staticClass:"custom-block tip"},[e("p",{staticClass:"custom-block-title"},[a._v("提示")]),a._v(" "),e("p",[a._v("Correct metadata is critical for good user experience in a ground station.")])])]),a._v(" "),e("p",[a._v("Parameter metadata can be stored anywhere in the source tree as either "),e("strong",[a._v(".c")]),a._v(" or "),e("strong",[a._v(".yaml")]),a._v(" parameter definitions (the YAML definition is newer, and more flexible). Typically it is stored alongside its associated module.")]),a._v(" "),e("p",[a._v("The build system extracts the metadata (using "),e("code",[a._v("make parameters_metadata")]),a._v(") to build the "),e("RouterLink",{attrs:{to:"/zh/advanced_config/parameter_reference.html"}},[a._v("parameter reference")]),a._v(" and the parameter information used by ground stations.")],1),a._v(" "),e("div",{staticClass:"custom-block warning"},[e("p",{staticClass:"custom-block-title"},[a._v("注意")]),a._v(" "),e("p",[a._v("After adding a "),e("em",[a._v("new")]),a._v(" parameter file you should call "),e("code",[a._v("make clean")]),a._v(" before building to generate the new parameters (parameter files are added as part of the "),e("em",[a._v("cmake")]),a._v(" configure step, which happens for clean builds and if a cmake file is modified).")])]),a._v(" "),e("h3",{attrs:{id:"c-参数-metadata"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#c-参数-metadata"}},[a._v("#")]),a._v(" c 参数 Metadata")]),a._v(" "),e("p",[a._v("The legacy approach for defining parameter metadata is in a file with extension "),e("strong",[a._v(".c")]),a._v(" (at time of writing this is the approach most commonly used in the source tree).")]),a._v(" "),e("p",[a._v("Parameter metadata sections look like the following examples:")]),a._v(" "),e("div",{staticClass:"language-cpp extra-class"},[e("pre",{pre:!0,attrs:{class:"language-cpp"}},[e("code",[e("span",{pre:!0,attrs:{class:"token comment"}},[a._v("/**\n * Pitch P gain\n *\n * Pitch proportional gain, i.e. desired angular speed in rad/s for error 1 rad.\n *\n * @unit 1/s\n * @min 0.0\n * @max 10\n * @decimal 2\n * @increment 0.0005\n * @reboot_required true\n * @group Multicopter Attitude Control\n */")]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("PARAM_DEFINE_FLOAT")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("MC_PITCH_P"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(",")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("6.5f")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("*")]),a._v("\n "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("*")]),a._v(" @unit "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("1")]),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("/")]),a._v("s\n "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("*")]),a._v(" @min "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("0.0")]),a._v("\n "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("*")]),a._v(" @max "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("10")]),a._v("\n "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("*")]),a._v(" @decimal "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("2")]),a._v("\n "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("*")]),a._v(" @increment "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("0.0005")]),a._v("\n "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("*")]),a._v(" @reboot_required "),e("span",{pre:!0,attrs:{class:"token boolean"}},[a._v("true")]),a._v("\n "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("*")]),a._v(" @group Multicopter Attitude Control\n "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("*")]),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("/")]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("PARAM_DEFINE_FLOAT")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("MC_PITCH_P"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(",")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("6.5f")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n")])])]),e("div",{staticClass:"language-cpp extra-class"},[e("pre",{pre:!0,attrs:{class:"language-cpp"}},[e("code",[e("span",{pre:!0,attrs:{class:"token comment"}},[a._v("/**\n * Acceleration compensation based on GPS\n * velocity.\n *\n * @group Attitude Q estimator\n * @boolean\n */")]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("PARAM_DEFINE_INT32")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("ATT_ACC_COMP"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(",")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("1")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("*")]),a._v("\n "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("*")]),a._v(" @group Attitude Q estimator\n "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("*")]),a._v(" @boolean\n "),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("*")]),e("span",{pre:!0,attrs:{class:"token operator"}},[a._v("/")]),a._v("\n"),e("span",{pre:!0,attrs:{class:"token function"}},[a._v("PARAM_DEFINE_INT32")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v("(")]),a._v("ATT_ACC_COMP"),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(",")]),a._v(" "),e("span",{pre:!0,attrs:{class:"token number"}},[a._v("1")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(")")]),e("span",{pre:!0,attrs:{class:"token punctuation"}},[a._v(";")]),a._v("\n")])])]),e("p",[a._v("The "),e("code",[a._v("PARAM_DEFINE_*")]),a._v(" macro at the end specifies the type of parameter ("),e("code",[a._v("PARAM_DEFINE_FLOAT")]),a._v(" or "),e("code",[a._v("PARAM_DEFINE_INT32")]),a._v("), the name of the parameter (which must match the name used in code), and the default value in firmware.")]),a._v(" "),e("p",[a._v("The lines in the comment block are all optional, and are primarily used to control display and editing options within a ground station. The purpose of each line is given below (for more detail see "),e("a",{attrs:{href:"https://github.com/PX4/PX4-Autopilot/blob/master/validation/module_schema.yaml",target:"_blank",rel:"noopener noreferrer"}},[a._v("module_schema.yaml"),e("OutboundLink")],1),a._v(").")]),a._v(" "),e("div",{staticClass:"language-cpp extra-class"},[e("pre",{pre:!0,attrs:{class:"language-cpp"}},[e("code",[e("span",{pre:!0,attrs:{class:"token comment"}},[a._v('/**\n * <title>\n *\n * <longer description, can be multi-line>\n *\n * @unit <the unit, e.g. m for meters>\n * @min <the minimum sane value. Can be overridden by the user>\n * @max <the maximum sane value. Can be overridden by the user>\n * @decimal <the minimum sane value. /**\n * <title>\n *\n * <longer description, can be multi-line>\n *\n * @unit <the unit, e.g. m for meters>\n * @min <the minimum sane value. Can be overridden by the user>\n * @max <the maximum sane value. Can be overridden by the user>\n * @decimal <the minimum sane value. Can be overridden by the user>\n * @increment <the "ticks" in which this value will increment in the UI>\n * @reboot_required true <add this if changing the param requires a system restart.>\n * @boolean <add this for integer parameters that represent a boolean value>\n * @group <a title for parameters that form a group>\n */')]),a._v("\n")])])]),e("h3",{attrs:{id:"yaml-metadata"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#yaml-metadata"}},[a._v("#")]),a._v(" YAML Metadata")]),a._v(" "),e("div",{staticClass:"custom-block note"},[e("p",{staticClass:"custom-block-title"},[a._v("注解")]),a._v(" "),e("p",[a._v("At time of writing YAML parameter definitions cannot be used in "),e("em",[a._v("libraries")]),a._v(".")])]),a._v(" "),e("p",[a._v("YAML meta data is intended as a full replacement for the "),e("strong",[a._v(".c")]),a._v(" definitions. It supports all the same metadata, along with new features like multi-instance definitions.")]),a._v(" "),e("ul",[e("li",[a._v("The YAML parameter metadata schema is here: "),e("a",{attrs:{href:"https://github.com/PX4/PX4-Autopilot/blob/master/validation/module_schema.yaml",target:"_blank",rel:"noopener noreferrer"}},[a._v("validation/module_schema.yaml"),e("OutboundLink")],1),a._v(".")]),a._v(" "),e("li",[a._v("An example of YAML definitions being used can be found in the MAVLink parameter definitions: "),e("a",{attrs:{href:"https://github.com/PX4/PX4-Autopilot/blob/master/src/modules/mavlink/module.yaml",target:"_blank",rel:"noopener noreferrer"}},[a._v("/src/modules/mavlink/module.yaml"),e("OutboundLink")],1),a._v(".")])]),a._v(" "),e("h4",{attrs:{id:"multi-instance-templated-meta-data"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#multi-instance-templated-meta-data"}},[a._v("#")]),a._v(" Multi-Instance (Templated) Meta Data")]),a._v(" "),e("p",[a._v("Templated parameter definitions are supported in "),e("a",{attrs:{href:"https://github.com/PX4/PX4-Autopilot/blob/master/validation/module_schema.yaml",target:"_blank",rel:"noopener noreferrer"}},[a._v("YAML parameter definitions"),e("OutboundLink")],1),a._v(" (templated parameter code is not supported).")]),a._v(" "),e("p",[a._v("The YAML allows you to define instance numbers in parameter names, descriptions, etc. using "),e("code",[a._v("${i}")]),a._v(". For example, below will generate MY_PARAM_1_RATE, MY_PARAM_2_RATE etc.")]),a._v(" "),e("div",{staticClass:"language- extra-class"},[e("pre",{pre:!0,attrs:{class:"language-text"}},[e("code",[a._v("MY_PARAM_${i}_RATE:\n            description:\n                short: Maximum rate for instance ${i}\n")])])]),e("p",[a._v("The following YAML definitions provide the start and end indexes.")]),a._v(" "),e("ul",[e("li",[e("code",[a._v("num_instances")]),a._v(" (default 1): Number of instances to generate (>=1)")]),a._v(" "),e("li",[e("code",[a._v("instance_start")]),a._v(" (default 0): First instance number. If 0, "),e("code",[a._v("${i}")]),a._v(" expands to [0, N-1]`.")])]),a._v(" "),e("p",[a._v("For a full example see the MAVLink parameter definitions: "),e("a",{attrs:{href:"https://github.com/PX4/PX4-Autopilot/blob/master/src/modules/mavlink/module.yaml",target:"_blank",rel:"noopener noreferrer"}},[a._v("/src/modules/mavlink/module.yaml"),e("OutboundLink")],1)]),a._v(" "),e("h2",{attrs:{id:"更多信息"}},[e("a",{staticClass:"header-anchor",attrs:{href:"#更多信息"}},[a._v("#")]),a._v(" 更多信息")]),a._v(" "),e("ul",[e("li",[e("RouterLink",{attrs:{to:"/zh/advanced_config/parameters.html"}},[a._v("查找/修改参数")])],1),a._v(" "),e("li",[e("RouterLink",{attrs:{to:"/zh/advanced_config/parameter_reference.html"}},[a._v("参数对照表")])],1)])])}),[],!1,null,null,null);t.default=n.exports}}]);