pixhawk控制板的ArduPilot固件编译

0. 环境

- ubuntu18(依赖python2和pip,建议直接ubuntu18不用最新的)
- pixhawk 2.4.8
- pixhawk 4

1. 获取源码

# 安装git

sudo apt install git

# 获取源码

cd ~/work
git clone --recurse-submodules https://github.com/ArduPilot/ardupilot
cd ardupilot


# 如果初次没顺利克隆子仓库,则:

git clone  https://github.com/ArduPilot/ardupilot
cd ardupilot
git submodule update --init --recursive

# 压缩源码备份

cd ~/work
7z a ardupilot_git_src_20240317.7z ardupilot


2. 安装依赖

$ ./Tools/environment_install/install-prereqs-ubuntu.sh
Install ArduPilot STM32 toolchain [N/y]?N

3. 安装交叉编译工具链


下载

https://firmware.ardupilot.org/Tools/STM32-tools/gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2


可以到这里浏览版本:

https://firmware.ardupilot.org/Tools/STM32-tools/


解压

tar -xjvf gcc-arm-none-eabi-10-2020-q4-major-x86_64-linux.tar.bz2


设置环境变量

export PATH=$PATH:/home/xxjianvm/work/gcc-arm-none-eabi-10-2020-q4-major/bin

4. 编译


# 设置环境变量

export PATH=$PATH:/home/xxjianvm/work/gcc-arm-none-eabi-10-2020-q4-major/bin
export PATH=$PATH:/home/xxjianvm/work/ardupilot/Tools/autotest
export PATH=/usr/lib/ccache:$PATH
source /home/xxjianvm/work/ardupilot/Tools/completion/completion.bash

# 配置

./waf list_boards
./waf configure --board fmuv3          # 3DR Pixhawk 2 boards
#./waf configure --board fmuv5          # Pixhawk 4

# 编译

./waf clean
#./waf rover
#./waf copter 

 

 

# 上传

./waf --targets bin/ardurover --upload

5. 问题集锦

问题:/usr/bin/python3: can't open file '/home/xxjianvm/work/ardupilot/modules/DroneCAN/dronecan_dsdlc/dronecan_dsdlc.py': [Errno 2] No such file or directory
分析:网络不好,浏览发现dronecan_dsdlc是空的
解决办法:把文件夹 dronecan_dsdlc 删除,再次执行 git submodule update --init --recursive

问题:dronecan_dsdlc.py: error: the following arguments are required: namespace_dir
分析:发现DroneCAN下的DSDL、libcanard又是空的

6. 参考


[Pixhawk] ardupilot源码windows编译教程,https://blog.csdn.net/Sandman06/article/details/115617932

Windows/Ubuntu操作系统下ArduPilot(APM)固件的编译方法,https://blog.csdn.net/oqqENvY12/article/details/60581036
ardupilot的编译过程,https://blog.csdn.net/u014220146/article/details/133068197
https://ardupilot.org/dev/docs/building-setup-linux.html#building-setup-linux
https://github.com/ArduPilot/ardupilot/blob/master/BUILD.md
https://github.com/pixhawk/Hardware

### Ardupilot 固件编译环境设置教程 #### 1. 安装必要的依赖项 为了成功编译 Ardupilot 固件,需要安装一些基础工具和库。以下是常见的 Linux 系统上的依赖项安装命令: 对于 Ubuntu 或 Debian 类系统: ```bash sudo apt-get update sudo apt-get install git python3-pip python3-setuptools gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential cmake ninja-build ``` 这些工具包括 Git(用于代码管理)、Python 及其扩展包、交叉编译器 `gcc-arm-none-eabi` 和构建工具 CMake[^1]。 #### 2. 配置 Git 环境并克隆项目 确保已正确配置 Git 的 SSH 密钥以便于访问 GitHub 上的资源。如果尚未完成此操作,请按照官方文档指南进行设置[^4]。 接着通过以下方式获取 Ardupilot 主仓库及其子模块: ```bash git clone --recurse-submodules https://github.com/ArduPilot/ardupilot.git cd ardupilot ``` 或者当遇到网络问题无法一次性拉取全部数据时可以尝试分步处理: ```bash git clone https://github.com/ArduPilot/ardupilot.git cd ardupilot git submodule update --init --recursive ``` 上述方法能够保证所有必需组件被同步下载下来[^3]。 #### 3. 更新子模块至最新状态 即使完成了初始克隆过程,仍需定期保持各部分处于最新版本之中。进入工作目录后运行如下脚本来实现这一目标: ```bash git pull origin master git submodule foreach 'git checkout $name || :' git submodule foreach 'git pull origin master || :' git submodule update --init --recursive ``` 这一步骤有助于解决可能存在的兼容性问题以及引入新特性支持。 #### 4. 检查可用硬件平台列表 在准备阶段完成后可查看当前环境中可供选择的目标设备清单: ```bash waf configure --list-boards ``` 该命令会打印出一系列由 Ardupilot 支持的具体飞行控制器型号名称[^2]。 #### 5. 开始实际编译流程 选定特定板卡作为输出对象之后即可启动正式建造环节。例如针对 Pixhawk 设备执行下面语句: ```bash waf clean waf configure -b sitl waf copter ``` 这里 `-b` 参数指定了所要生产的机型类别;而最后一条指令则指示生成对应类型的固件文件。 --- ### 总结 以上便是关于如何搭建 Ardupilot 固件开发所需软硬件条件的整体介绍。从基本软件栈部署直至最终产物产出均有所涉及。希望这份资料能帮助到正在探索无人机技术领域的朋友!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值