Ubuntu16.04下如何编译 ardupilot

来源:互联网 发布:java todo和 编辑:程序博客网 时间:2024/06/06 01:27

根据官方文档 http://dev.ardupilot.com/wiki/building-the-code-onlinux/

先安装git ,  而后用 git clone下载源文件

1)下载源代码

sudo apt-get -qq -y install git
git clone https://github.com/diydrones/ardupilot.git

(如果不想clone整个库,到https://github.com/openpilot/OpenPilot下载zip文件有问题,因为编译过程中会调git命令取文件取不到,因为没有git库)


2) 而后安装toolchain (如:arduino-core,  gcc-avr avrdude avr-libc binutils-avr 等)

最简单就是运行下面脚本(提示不多,可能等很长时间)

ardupilot/Tools/scripts/install-prereqs-ubuntu.sh -y


不运行这个脚本,就要手动运行下面命令

sudo apt-get install gcc-avr avrdude avr-libc binutils-avr

sudo apt-get install python-serial python-wxgtk2.8 python-matplotlib python-opencv python-pexpect python-scipy
sudo apt-get gawk make git arduino-core g++


pixhawk 需要下载 arm toolchain

在ubuntu14.04不要用sudo apt-get install gcc-arm-none-eabi -y, 不但安装了错误的版本,而且缺少 c++ header

而应该运行 http://dev.px4.io/starting-installing-linux-boutique.html 提示的脚本(用wget 下载,再安装)


3)编译

使当前shell 环境变量生效

. ~/.profile


注意:此次操作是路径配置,如果你是从别的地方烤的文件,就在该文件所在的目录下运行他,即可配置路径。否则无法编译成功。会提示“gcc-arm-none-eabi。。。。。”的错误。


编译多轴
cd ardupilot/ArduCopter
make 

根据提示选择target

 Targets
 -------

  px4-v1 - the PX4v1 board
  px4-v2 - the Pixhawk
  pxf - the Beagle Bone Black (BBB) + PXF cape combination
  navio - the RaspberryPi + NavIO cape combination
  linux - a generic Linux build
  flymaple - the FlyMaple board

...


新版本的ArduCopter(3.x) 不支持缺省参数,而且取消了 apm1/apm2, 添加了树莓派的支持


比如编译 pixhawk 

make px4-v2


ArduPlane  APMrover2 AntennaTracker 与此类似

最后看到下面提示,就成功编译生成文件

LINK:    /home/payne/ardupilot/ardupilot/modules/PX4Firmware/Build/px4fmu-v2_APM.build/firmware.elf

BIN:     /home/payne/ardupilot/ardupilot/modules/PX4Firmware/Build/px4fmu-v2_APM.build/firmware.bin
%% Generating /home/payne/ardupilot/ardupilot/modules/PX4Firmware/Build/px4fmu-v2_APM.build/firmware.px4
make[2]: Leaving directory `/home/payne/ardupilot/ardupilot/modules/PX4Firmware/Build/px4fmu-v2_APM.build'
%% Copying /home/payne/ardupilot/ardupilot/modules/PX4Firmware/Images/px4fmu-v2_APM.px4
make[1]: Leaving directory `/home/payne/ardupilot/ardupilot'
   text    data     bss     dec     hex filename
 901640    2812   62352  966804   ec094 /home/payne/ardupilot/ardupilot/modules/PX4Firmware/Build/px4fmu-v2_APM.build/firmware.elf
PX4 ArduCopter Firmware is in ArduCopter-v2.px4



最后用 make px4-v2-upload 上传


其他问题:

我想到ArduPlane去编apm2 ( Copter取消了对apm2的支持,Plane应该没有取消吧)

但提示

ArduPlane$ make apm2
../mk/targets.mk:13: *** apm2 is deprecated on master branch; use master-AVR


那么就先运行

git checkout master-AVR

再编就可以了

make apm2

得到

%% ArduPlane.elf
Firmware is in ArduPlane.elf
%% ArduPlane.eep

%% ArduPlane.hex

如果编译不成功:

检查gcc是否安装:arm-none-eabi-g++ -v

如果没有安装,控制台会提醒你安装,并提供安装指令,运行指令即可安装;

安装genromfs:sudo apt-get install genromfs

安装python-empysudo apt-get install python-empy 

如上操作编译不成功问题基本可以解决,若还是编译不能通过,根据报错原因,安装相应的文件。

转自http://blog.csdn.net/span76/article/details/49782015 很有用

原创粉丝点击