当前位置:   article > 正文

pixhawk控制板的ArduPilot固件编译

pixhawk控制板的ArduPilot固件编译

0. 环境

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

1. 获取源码

# 安装git

sudo apt install git

# 获取源码

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


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

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

# 压缩源码备份

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


2. 安装依赖

  1. $ ./Tools/environment_install/install-prereqs-ubuntu.sh
  2. 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. 编译


# 设置环境变量

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

# 配置

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

# 编译

  1. ./waf clean
  2. #./waf rover
  3. #./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. 参考

  1. [Pixhawk] ardupilot源码windows编译教程,https://blog.csdn.net/Sandman06/article/details/115617932
  2. Windows/Ubuntu操作系统下ArduPilot(APM)固件的编译方法,https://blog.csdn.net/oqqENvY12/article/details/60581036
  3. ardupilot的编译过程,https://blog.csdn.net/u014220146/article/details/133068197
  4. https://ardupilot.org/dev/docs/building-setup-linux.html#building-setup-linux
  5. https://github.com/ArduPilot/ardupilot/blob/master/BUILD.md
  6. https://github.com/pixhawk/Hardware

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号