APM和PX4是唯二的目前主流的开源飞控。相比较PX4,APM项目代码较为简洁高效,同时也符合目前开源飞控的一些主流协议。了解APM可以从下载和建造它的开源飞控项目开始。选择的系统为Ubuntu 22.04。
参考链接:
https://blog.youkuaiyun.com/w8www/article/details/148705284
https://github.com/ArduPilot/ardupilot/blob/master/BUILD.md
1 项目下载
从GitHub下载开源项目,在命令行输入
$ git clone --recursive https://github.com/ArduPilot/ardupilot
需要较长时间,其中包含多个子项目,如果考虑到网络连接稳定性,也可以采用分步的方式下载,如下
$ git clone https://github.com/ArduPilot/ardupilot
$ cd ardupilot
$ git submodule update --init --recursive
最后一个命令可以多次执行,以保证每一个子项目下载完整。
2 项目编译
进入到项目目录
$ cd ardupilot
目前ardupilot项目通过waf命令来进行编译,通常的编译顺序示例如下
$ ./waf config --board CubeBlack
$ ./waf copter
先对编译进行设置,–board CubeBlack 表示适配的板卡类型,常用的板卡类型有
./waf configure --board bebop --static # Bebop or Bebop2
./waf configure --board edge # emlid edge
./waf configure --board fmuv3 # 3DR Pixhawk 2 boards
./waf configure --board navio2 # emlid navio2
./waf configure --board Pixhawk1 # Pixhawk1
./waf configure --board CubeBlack # Hex/ProfiCNC Cube Black (formerly known as Pixhawk 2.1)
./waf configure --board Pixracer # Pixracer
./waf configure --board skyviper-v2450 # SkyRocket's SkyViper GPS drone using ChibiOS
./waf configure --board sitl # software-in-the-loop simulator
./waf configure --board sitl --debug # software-in-the-loop simulator with debug symbols
其中,sitl是一个很有用的选项,用于建立用于仿真环境的程序,在后面会介绍到。
后面的waf命令正式编译项目,copter为编译选项,表示编译生成多旋翼飞行器的飞行控制程序。也有多种类型可以选择。
./waf copter # All multirotor types
./waf heli # Helicopter types
./waf plane # Fixed wing airplanes including VTOL
./waf rover # Ground-based rovers and surface boats
./waf sub # ROV and other submarines
./waf antennatracker # Antenna trackers
./waf AP_Periph # AP Peripheral
这样就编译完成,编译完成后,会在项目的
build/[board_type]/bin
子目录中产生相应的飞控程序,其中board_type表示板卡类型,如CubeBlack、fmuv3、sitl等