由于需要在GitHub下载代码,而国内访问受限,可能会出现一些问题,这里建议使用github国内镜像,参看:GitHub国内镜像网站,当然下面会给出具体解决方案。
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)
cd PX4-Autopilotgit submodule update --init --recursive注意:
若该步骤出错,归根到底还是因为github访问不稳定。解决方案如下:
(方案的总体原则就是改变源码里面各个.gitmodules文件里的下载地址,需要注意的是源码位置,我这里是将源码放在主文件夹下,也就是 ~/PX4_Autopilot)
cd ~/PX4_Autopilotgedit .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_5git submodule update --initcd ~/PX4_Autopilot/src/drivers/uavcan/libuavcangedit .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.gitgit submodule update --initcd ~/PX4_Autopilot/Tools/jMAVSimgedit .gitmodules[submodule "jMAVlib"] path = jMAVlib url = https://gitee.com/robin_shaun/jMAVlib branch = mastergit submodule update --initcd ~/PX4_Autopilot/Tools/sitl_gazebogedit .gitmodules[submodule "external/OpticalFlow"] path = external/OpticalFlow url = https://gitee.com/robin_shaun/OpticalFlowgit submodule update --initcd ~/PX4_Autopilot/platforms/qurt/dspalgedit .gitmodules[submodule "cmake_hexagon"] path = cmake_hexagon url = https://gitee.com/robin_shaun/cmake_hexagongit submodule update --initcd ~/PX4_Autopilot/src/drivers/uavcan/libuavcan/libuavcan/dsdl_compiler/pyuavcangedit .gitmodules[submodule "dsdl"] path = dsdl url = https://gitee.com/robin_shaun/dsdlgit submodule update --initcd ~/PX4_Autopilot/Tools/sitl_gazebo/external/OpticalFlowgedit .gitmodules[submodule "external/klt_feature_tracker"] path = external/klt_feature_tracker url = https://gitee.com/robin_shaun/klt_feature_trackergit submodule update --initgit submodule update --initcd ~/PX4_Firmwaremake px4_sitl_default gazebo注意:
这一步可能会报错:ninja: build stopped: subcommand failed.
不要慌!
git submodule update --init --recursivemake cleanmake px4_sitl_default gazebo