由於需要在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-Autopilot
git submodule update --init --recursive
注意:
若該步驟出錯,歸根到底還是因為github存取不穩定。解決方案如下:
(方案的總體原則就是改變原始碼裡面各個.gitmodules
檔案裡的下載地址,需要注意的是原始碼位置,我這裡是將原始碼放在主資料夾下,也就是 ~/PX4_Autopilot
)
cd ~/PX4_Autopilot
gedit .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
git submodule update --init
cd ~/PX4_Autopilot/src/drivers/uavcan/libuavcan
gedit .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
git submodule update --init
cd ~/PX4_Autopilot/Tools/jMAVSim
gedit .gitmodules
[submodule "jMAVlib"]
path = jMAVlib
url = https://gitee.com/robin_shaun/jMAVlib
branch = master
git submodule update --init
cd ~/PX4_Autopilot/Tools/sitl_gazebo
gedit .gitmodules
[submodule "external/OpticalFlow"]
path = external/OpticalFlow
url = https://gitee.com/robin_shaun/OpticalFlow
git submodule update --init
cd ~/PX4_Autopilot/platforms/qurt/dspal
gedit .gitmodules
[submodule "cmake_hexagon"]
path = cmake_hexagon
url = https://gitee.com/robin_shaun/cmake_hexagon
git submodule update --init
cd ~/PX4_Autopilot/src/drivers/uavcan/libuavcan/libuavcan/dsdl_compiler/pyuavcan
gedit .gitmodules
[submodule "dsdl"]
path = dsdl
url = https://gitee.com/robin_shaun/dsdl
git submodule update --init
cd ~/PX4_Autopilot/Tools/sitl_gazebo/external/OpticalFlow
gedit .gitmodules
[submodule "external/klt_feature_tracker"]
path = external/klt_feature_tracker
url = https://gitee.com/robin_shaun/klt_feature_tracker
git submodule update --init
git submodule update --init
cd ~/PX4_Firmware
make px4_sitl_default gazebo
注意:
這一步可能會報錯:ninja: build stopped: subcommand failed.
不要慌!
git submodule update --init --recursive
make clean
make px4_sitl_default
make px4_sitl_default gazebo
注意:
如果gazebo出不來,可以這麼做:
make distclean
sudo apt-get install ros-melodic-gazebo-dev
make px4_sitl_default gazebo