1.创建新模块文件夹
路径: ardupilot\libraries
创建 AP_XXX文件夹
2.添加宏使能开关
#ifndef AP_XXX_ENABLED
#define AP_XXX_ENABLED ENABLED
#endif
3.添加新模块文件夹编译路径
ap_libraries=bld.ap_common_vehicle_libraries() + [
...
'AP_XXX',
],
4.在copter.h添加头文件
#if AP_XXX_ENABLED == ENABLED
#include <AP_XXX/AP_XXX.h>
#endif
5.在copter类定义
#if AP_XXX_ENABLED == ENABLED
AP_XXX XXX;
#endif
6.如果需要创建任务,则在copter.cpp中 scheduler_tasks[]添加任务
#if AP_XXX_ENABLED == ENABLED
SCHED_TASK_CLASS(AP_XXX, &copter.XXX, update, 200, 10, 140),
#endif
7.添加模块初始化
void Copter::init_ardupilot()
{
....
xxx.init();
}