[Pixhawk/PX4]開發環境搭建(Ubuntu 18.04)


本文主要記錄了PX4環境在Ubuntu 18.04下的搭建過程,由於我在安裝PX4環境之前已經先安裝了ROS Melodic,而安裝ROS的時候同時安裝了gazebo,因此無法確定后面出現的問題是否由於先安裝了ROS

本文分為以下幾個部分:

  1. 使用官方推薦的安裝腳本進行安裝
  2. 解決安裝過程中出現的問題
  3. 下載PX4源碼
  4. 視頻記錄

請注意

以下安裝過程全部在手機熱點下完成,如果你是校園網用戶並且下載速度過慢,請嘗試使用手機熱點。

1. 使用官方推薦的安裝腳本進行安裝

打開PX4_Ubuntu安裝頁面,然后按照官方推薦的使用腳本進行安裝,選擇安裝腳本ubuntu.sh

1. 下載ubuntu.sh和requirements.txt

wget https://raw.githubusercontent.com/PX4/Firmware/master/Tools/setup/ubuntu.sh 
wget https://raw.githubusercontent.com/PX4/Firmware/master/Tools/setup/requirements.txt

2. 運行ubuntu.sh

source ubuntu.sh

3. 等待安裝完成

安裝完成后,會在終端提示重啟電腦。

ubuntu-sh.png

安裝完成后,你可以通過檢查gcc版本來檢查是否成功安裝Nuttx

$arm-none-eabi-gcc --version

 arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 7.2.1 20170904 (release) [ARM/embedded-7-branch revision 255204]
 Copyright (C) 2017 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

2. 解決安裝過程中出現的問題

1.python包安裝過慢

安裝過程中,在安裝python的依賴時,由於直接從國外的pip源進行獲取,導致速度太慢

打開下載的ubuntu.sh,找到下面幾行:

# Python3 dependencies
echo
echo "Installing PX4 Python3 dependencies"
sudo python3 -m pip install --upgrade pip setuptools wheel
sudo python3 -m pip install -r ${DIR}/requirements.txt


# Python2 dependencies
echo
echo "Installing PX4 Python2 dependencies"
sudo python2 -m pip install --upgrade pip setuptools wheel
sudo python2 -m pip install -r ${DIR}/requirements.txt

將其修改為

# Python3 dependencies
echo
echo "Installing PX4 Python3 dependencies"
sudo python3 -m pip install --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple pip setuptools wheel
sudo python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r ${DIR}/requirements.txt


# Python2 dependencies
echo
echo "Installing PX4 Python2 dependencies"
sudo python2 -m pip install --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple pip setuptools wheel
sudo python2 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r ${DIR}/requirements.txt

在這之后,重新運行

source ubuntu.sh

2.交叉編譯器gcc下載過慢

可以直接打開ubuntu.sh,在其中找到該編譯器的下載地址,並將該地址

https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/7-2017q4/gcc-arm-none-eabi-7-2017-q4-major-linux.tar.bz2

復制到瀏覽器進行下載,下載完成后,要參照着ubuntu.sh手動運行命令完成安裝。

3.下載PX4源碼

導航到你的home目錄下,運行命令

git clone https://github.com/PX4/Firmware.git

下載過程比較緩慢,等待下載完成以后,運行命令

運行命令

git submodule update --init --recursive 

4.gazebo仿真

打開終端到Firmware文件夾,運行命令

make px4_sitl gazebo_iris

gazebo.png

4.視頻記錄

同時,我還將我的安裝過程錄制成了視頻,請點擊這里查看。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM