OEM 定制
ArduPilot为OEM提供了几种方法,以提供其产品上符合其特定系统配置的固件:
- 具备特定默认参数以匹配包含的系统组件,如gimbals,或整个系统的外围设备,如即时飞行机体的能力. 这使得用户在遇到参数被意外更改的问题时,可以使用Mission Planner或MAVProxy"重置为默认",并且最多只需重新校准罗盘/IMU/和RC即可准备飞行.
- 能够为特殊功能提供ROM中的Lua脚本,而终端用户无需在SD卡上加载. 更多信息, 请访问ArduPilot 的 Lua 脚本这里.
- 更改显示给用户的固件字符串的能力 。
- 能够将图片和信息文件包含在可用的免费闪存空间中.
- 能够改变参数并将其标记为只读的,以便用户不能使用这些参数。APJ 工具.(截至4.5版固件,此已无法使用)
- 能力安装 LUA 脚本以审查参数在允许通过 MAVLink 设置它们之前。
Customization Steps
This section assumes that the OEM has set up the build environment (building-the-code) and cloned the ArduPilot GitHub repo locally (where-to-get-the-code), to build its customized version of the firmware.
Create a branch with the version of firmware you wish to base the customization upon. This will usually be the current stable version. To do this for ArduPlane Stable, for example, assuming you are already in the ArduPilot directory on your PC:
git fetch https://github.com/ArduPilot/ardupilot.git <version> where <version> is the tag for the stable version for the desired vehicle: ArduPlane-stable, ArduCopter-stable, APMrover2-stable,etc. git checkout -b <your branch name> FETCH_HEAD git submodule update --init --recursiveIn the
directory, create a new subdirectory for your customized board definitions. In this example, the directory will be namedlibraries/AP_HAL_ChibiOS/hwdefto create a derivative for that board.OEM_CubeOrangeCreate a new
file in this format. In this case, our ready-to-fly plane will be using a CubeOrange autopilot and only requires a single line:hwdef.datinclude ../CubeOrange/hwdef.dat
The firmware name can be customized by adding one line to the
file.hwdef.datdefine AP_CUSTOM_FIRMWARE_STRING "MyMagicFrame"
说明:
Custom frame type strings can be created through Lua the scripting method
.motors:set_frame_string("Custom frame name")Now in that same directory, copy the base board's
bootloader file, and then include a file namedhwdef-bl.dat. This file will be the parameter overrides of the standard defaults to match your system's configuration. Things like output function assignments, auxiliary RC switches, flight and tuning parameters, etc.defaults.parm
说明:
a parameter can be made readonly (ie user cannot change its value) by marking it in the file@READONLY
警告:
The file should be as small as possible. Some boards only allow 1024 bytes total for this file. Every ASCII byte in the file counts against this limit (except for comment lines). Use integer values where possible. Below is a simple example. Serial port protocols,baud rate,and options defaults can be set directly in the hwdef, as well as NTF_LED_TYPES, and battery monitor defaults, and should be done there instead of a defaults file.defaults.parm
# setup for NTF LEDs on output5 SERVO5_FUNCTION 120 NTF_LED_TYPES 256
- You can also embed Lua scripts in the ROM of the chip that will automatically run. Since Lua is currently only run on autopilots with a lot of flash space, they are only restricted in total aggregate size to available free flash memory. Put the scripts in a sub-directory called
, i.e.scripts. Files must end inlibraries/AP_HAL_ChibiOS/hwdef/OEM_CubeOrange/scripts..lua
Alternatively, you can specify the LUA applet or driver at compile by using the "--embed-<filename> command, for example:
./waf plane --embed-LTE_modem警告:
The user may also run Lua scripts off the SD card, so care should be taken in naming the embedded script file names to not conflict with potential user file names. It is recommended that the file names of embedded Lua scripts be provided in the product documentation for the user.
- You can also embed small pieces of documentation in the ROM of the chip that are readable when examining the @ROMFS folder via MAVFtp. These can be pictures or small informational documents. These must fit within the free flash space of the autopilot. These files can be located in sub-directories in
(e.g.libraries/AP_HAL_ChibiOS/hwdef/OEM_CubeOrange).libraries/AP_HAL_ChibiOS/hwdef/OEM_CubeOrange/AircraftManual - Now build as normal with OEM-CubeOrange as the board name in the configuration. The default parameters, Lua scripts, and the custom firmware name will be embedded appropriately.
Alternative To Customizing hwdef.dat
Instead of creating a separate branch and modifying the hwdef file,
you can also insert Lua scripts or even informational files into the
ROMFS of the build. Simply go to the top level of your ArduPilot git
checkout and create a sub-folder named "ROMFS_custom" in the root of
the source tree. Place your LUA scripts in a sub-folder in this
directory, named "scripts" (i.e. the path
). You can have other sub-folders
for informational files and these will be included and viewable when
examining the @ROMFS folder with MAVFtp.ardupilot/ROMFS_custom/scripts
[copywiki destination="plane,copter,rover,sub,dev"]
【本页后半部分仍为英文原文摘录,补译中。】
译自 ArduPilot Copter「OEM Customization」· 查看原文 · CC BY-SA 3.0