本文的開發環境是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
https://github.com/ArduPilot/ardupilot/blob/master/BUILD.md