本文的开发环境是Ubuntu18.04。如果操作系统是Ubuntu其他版本的话问题不大,如果是Windows操作系统的小伙伴请绕道。
一、源码下载及相关配置
1.ardupilot 代码可以直接在github上搜索下载,也可以使用如下命令直接clone。
git clone https://github.com/ArduPilot/ardupilot
2.进入源代码文件夹
cd ardupilot
3.更新子模块
git submodule update --init --recursive
4.安装所需的包
Tools/scripts/install-prereqs-ubuntu.sh -y
5.重新加载路径
. ~/.profile
二、源码的编译
ardupilot源码的编译与px4的编译不同。px4直接使用make 命令编译,而ardupilot使用Waf工具编译。因此ardupilot编译命令也有所不同。具体如下:
1.进入源代码文件夹
cd ardupilot
2.查看源码支持的板子
./waf list_boards
3.配置代码运行的板子(硬件环境,根据自己具体的飞控板决定)。
./waf configure --board px4-v3
4.编译并下载
./waf --targets bin/arducopter --upload
参考文档:
http://ardupilot.org/dev/docs/building-setup-linux.html#building-setup-linux