0.前言

由于需要在GitHub下载代码,而国内访问受限,可能会出现一些问题,这里建议使用github国内镜像,参看:GitHub国内镜像网站,当然下面会给出具体解决方案。

1.步骤

1.1下载源码:git clone https://github.com/PX4/PX4-Autopilot.git

注意:

若该步骤出错,使用镜像,也就是运行:git clone https://hub.fastgit.xyz/PX4/PX4-Autopilot.git

或者使用gitee镜像:git clone https://gitee.com/robin_shaun/PX4_Firmware(注意使用这个方法时的源码文件名是PX4_Firmware)

1.2 切换到源码文件夹:cd PX4-Autopilot

1.3 更新工程子模块git submodule update --init --recursive

注意:

若该步骤出错,归根到底还是因为github访问不稳定。解决方案如下:

(方案的总体原则就是改变源码里面各个.gitmodules文件里的下载地址,需要注意的是源码位置,我这里是将源码放在主文件夹下,也就是 ~/PX4_Autopilot)

(1)源码主文件夹下

  1. cd ~/PX4_Autopilot
  2. gedit .gitmodules

    (注意:这里主要是为了修改文件,我用的是gedit编辑器,也可以用vim, nano,vs code之类的,后面相同)

    将 .gitmodules 中的内容更换为:
[submodule "mavlink/include/mavlink/v2.0"]
path = mavlink/include/mavlink/v2.0
url = https://gitee.com/robin_shaun/c_library_v2.git
branch = master
[submodule "src/drivers/uavcan/libuavcan"]
path = src/drivers/uavcan/libuavcan
url = https://gitee.com/robin_shaun/uavcan.git
branch = px4
[submodule "Tools/jMAVSim"]
path = Tools/jMAVSim
url = https://gitee.com/robin_shaun/jMAVSim.git
branch = master
[submodule "Tools/sitl_gazebo"]
path = Tools/sitl_gazebo
url = https://gitee.com/robin_shaun/sitl_gazebo.git
branch = master
[submodule "src/lib/matrix"]
path = src/lib/matrix
url = https://gitee.com/robin_shaun/Matrix.git
branch = master
[submodule "src/lib/ecl"]
path = src/lib/ecl
url = https://gitee.com/robin_shaun/ecl.git
branch = master
[submodule "boards/atlflight/cmake_hexagon"]
path = boards/atlflight/cmake_hexagon
url = https://gitee.com/robin_shaun/cmake_hexagon.git
branch = px4
[submodule "src/drivers/gps/devices"]
path = src/drivers/gps/devices
url = https://gitee.com/robin_shaun/GpsDrivers.git
branch = master
[submodule "src/modules/micrortps_bridge/micro-CDR"]
path = src/modules/micrortps_bridge/micro-CDR
url = https://gitee.com/robin_shaun/micro-CDR.git
branch = px4
[submodule "platforms/nuttx/NuttX/nuttx"]
path = platforms/nuttx/NuttX/nuttx
url = https://gitee.com/robin_shaun/NuttX.git
branch = px4_firmware_nuttx-9.1.0+
[submodule "platforms/nuttx/NuttX/apps"]
path = platforms/nuttx/NuttX/apps
url = https://gitee.com/robin_shaun/NuttX-apps.git
branch = px4_firmware_nuttx-9.1.0+
[submodule "platforms/qurt/dspal"]
path = platforms/qurt/dspal
url = https://gitee.com/robin_shaun/dspal.git
[submodule "Tools/flightgear_bridge"]
path = Tools/flightgear_bridge
url = https://gitee.com/robin_shaun/PX4-FlightGear-Bridge.git
branch = master
[submodule "Tools/jsbsim_bridge"]
path = Tools/jsbsim_bridge
url = https://gitee.com/robin_shaun/px4-jsbsim-bridge.git
[submodule "src/examples/gyro_fft/CMSIS_5"]
path = src/examples/gyro_fft/CMSIS_5
url = https://gitee.com/mirrors/CMSIS_5
  1. git submodule update --init

(2) libuavcan文件夹

  1. cd ~/PX4_Autopilot/src/drivers/uavcan/libuavcan
  2. gedit .gitmodules

    将 .gitmodules 中的内容更换为:
[submodule "dsdl"]
path = dsdl
url = https://gitee.com/robin_shaun/dsdl
branch = legacy-v0
[submodule "libuavcan/dsdl_compiler/pyuavcan"]
path = libuavcan/dsdl_compiler/pyuavcan
url = https://gitee.com/robin_shaun/pyuavcan
[submodule "libuavcan_drivers/kinetis"]
path = libuavcan_drivers/kinetis
url = https://gitee.com/robin_shaun/libuavcan_kinetis.git
  1. git submodule update --init

(3) jMAVSim文件夹

  1. cd ~/PX4_Autopilot/Tools/jMAVSim
  2. gedit .gitmodules

    将 .gitmodules 中的内容更换为:
[submodule "jMAVlib"]
path = jMAVlib
url = https://gitee.com/robin_shaun/jMAVlib
branch = master
  1. git submodule update --init

(4) sitl_gazebo文件夹

  1. cd ~/PX4_Autopilot/Tools/sitl_gazebo
  2. gedit .gitmodules

    将 .gitmodules 中的内容更换为:
[submodule "external/OpticalFlow"]
path = external/OpticalFlow
url = https://gitee.com/robin_shaun/OpticalFlow
  1. git submodule update --init

(5) dspal文件夹

  1. cd ~/PX4_Autopilot/platforms/qurt/dspal
  2. gedit .gitmodules

    将 .gitmodules 中的内容更换为:
[submodule "cmake_hexagon"]
path = cmake_hexagon
url = https://gitee.com/robin_shaun/cmake_hexagon
  1. git submodule update --init

(6) pyuavcan文件夹

  1. cd ~/PX4_Autopilot/src/drivers/uavcan/libuavcan/libuavcan/dsdl_compiler/pyuavcan
  2. gedit .gitmodules

    将 .gitmodules 中的内容更换为:
[submodule "dsdl"]
path = dsdl
url = https://gitee.com/robin_shaun/dsdl
  1. git submodule update --init

(7) OpticalFlow文件夹

  1. cd ~/PX4_Autopilot/Tools/sitl_gazebo/external/OpticalFlow
  2. gedit .gitmodules

    将 .gitmodules 中的内容更换为:
[submodule "external/klt_feature_tracker"]
path = external/klt_feature_tracker
url = https://gitee.com/robin_shaun/klt_feature_tracker
  1. git submodule update --init

(8)终于修改完了,可以再次运行下这句命令

git submodule update --init

1.4 编译

cd ~/PX4_Firmware
make px4_sitl_default gazebo

注意:

这一步可能会报错:ninja: build stopped: subcommand failed.



不要慌!

  1. 先看看子模块是否更新成功。执行命令:git submodule update --init --recursive

    linux哲学,没有消息就是好消息,如果没有出现任何内容,说明子模块更新成功(看不懂什么是子模块也没问题,意思就是到此为止,没问题)。
  2. 接下来清理下make环境就ok了:make clean
  3. 最后再执行一次编译命令:make px4_sitl_default gazebo

    以下是我成功的界面

2. 祝你配置顺利!如有问题,欢迎讨论!

最新文章

  1. [笔记]ubuntu安装flashplayer
  2. F#之旅1 - Why use F#?为什么要用F#?
  3. day3 Linux基础
  4. Runner站立会议07
  5. http request method and response codes
  6. unity3d项目文件目录发布后,对应的ios/android应用目录[转]
  7. 在HTML标签<a/>中调用javascript代码
  8. tar exclue文件夹
  9. 实践JAVA wait(), notify(),sleep方法--一道多线程的面试题
  10. 集群——LVS理论(转)
  11. 2015_WEB页面前端工程师_远程测题_东方蜘蛛_1
  12. svn 1.8.11 命令行提交新添加文件错误
  13. ISO14443-4块传输协议的实现
  14. JS判断手机端和PC端自动跳转
  15. 如何在KEIL中编写模块化的C程序
  16. js数组和对象互转方法
  17. 关于文件目录等的特殊权限setuid, setgid , sticky chattr, lsattr
  18. hashlib,hmac,subprocess,configparser,xlrd,xlwt,xml模块基本功能
  19. Arrays和String单元测试-20175218
  20. 剑指offer(4)

热门文章

  1. Java在方法中定义可变参数类型
  2. for 循环打印直角三角形、正三角形、棱形
  3. Tsunami: A Learned Multi-dimensional Index for Correlated Data and Skewed Workloads 论文解读(VLDB 2021)
  4. LC-141andLC-142
  5. 解决帝国CMS搜索页面模板不支持灵动标签和万能标签的方法
  6. springboot jar包方式部署
  7. Sliding Window - 题解【单调队列】
  8. Envoy熔断限流实践(一)基于Rainbond插件实现熔断
  9. JavaWeb和WebGIS学习笔记(七)——MapGuide Open Source安装、配置以及MapGuide Maestro发布地图——超详细!目前最保姆级的MapGuide上手指南!
  10. Hadoop(二)Hdfs基本操作