[Pixhawk/PX4]开发环境搭建(Ubuntu 18.04)
<p>本文主要记录了<code>PX4</code>环境在<code>Ubuntu 18.04</code>下的搭建过程,由于我在安装PX4环境之前已经先安装了<code>ROS Melodic</code>,而安装<code>ROS</code>的时候同时安装了<code>gazebo</code>,因此无法确定后面出现的问题是否由于先安装了<code>ROS</code>。</p><p>本文分为以下几个部分:</p>
<ol>
<li>使用官方推荐的安装脚本进行安装</li>
<li>解决安装过程中出现的问题</li>
<li>下载PX4源码</li>
<li>视频记录</li>
</ol>
<p><strong>请注意</strong>:</p>
<p>以下安装过程全部在手机热点下完成,如果你是校园网用户并且下载速度过慢,请尝试使用手机热点。</p>
<h3 id="1-使用官方推荐的安装脚本进行安装">1. 使用官方推荐的安装脚本进行安装</h3>
<p>打开PX4_Ubuntu安装页面,然后按照官方推荐的使用脚本进行安装,选择安装脚本<code>ubuntu.sh</code>。</p>
<h4 id="1-下载ubuntush和requirementstxt">1. 下载ubuntu.sh和requirements.txt</h4>
<pre><code class="language-bash">wget https://raw.githubusercontent.com/PX4/Firmware/master/Tools/setup/ubuntu.sh
wget https://raw.githubusercontent.com/PX4/Firmware/master/Tools/setup/requirements.txt
</code></pre>
<h4 id="2-运行ubuntush">2. 运行ubuntu.sh</h4>
<pre><code class="language-bash">source ubuntu.sh
</code></pre>
<h4 id="3-等待安装完成">3. 等待安装完成</h4>
<p>安装完成后,会在终端提示重启电脑。</p>
<p><img src="https://i.postimg.cc/wBCxdt8y/ubuntu-sh.png"></p>
<p>安装完成后,你可以通过检查<code>gcc</code>版本来检查是否成功安装<code>Nuttx</code></p>
<pre><code class="language-bash">$arm-none-eabi-gcc --version
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 7.2.1 20170904 (release)
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.
</code></pre>
<h3 id="2-解决安装过程中出现的问题">2. 解决安装过程中出现的问题</h3>
<h4 id="1python包安装过慢">1.python包安装过慢</h4>
<p>安装过程中,在安装<code>python</code>的依赖时,由于直接从国外的<code>pip</code>源进行获取,<strong>导致速度太慢</strong>。</p>
<p>打开下载的<code>ubuntu.sh</code>,找到下面几行:</p>
<pre><code class="language-bash"># 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
</code></pre>
<p>将其修改为</p>
<pre><code class="language-bash"># 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
</code></pre>
<p>在这之后,重新运行</p>
<pre><code class="language-bash">source ubuntu.sh
</code></pre>
<h4 id="2交叉编译器gcc下载过慢">2.交叉编译器gcc下载过慢</h4>
<p>可以直接打开<code>ubuntu.sh</code>,在其中找到该编译器的下载地址,并将该地址</p>
<blockquote>
<p>https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/7-2017q4/gcc-arm-none-eabi-7-2017-q4-major-linux.tar.bz2</p>
</blockquote>
<p>复制到浏览器进行下载,下载完成后,要参照着<code>ubuntu.sh</code>手动运行命令完成安装。</p>
<h3 id="3下载px4源码">3.下载PX4源码</h3>
<p>导航到你的<code>home</code>目录下,运行命令</p>
<pre><code class="language-bash">git clone https://github.com/PX4/Firmware.git
</code></pre>
<p>下载过程比较缓慢,等待下载完成以后,运行命令</p>
<p>运行命令</p>
<pre><code class="language-bash">git submodule update --init --recursive
</code></pre>
<p>4.gazebo仿真</p>
<p>打开终端到<code>Firmware</code>文件夹,运行命令</p>
<pre><code class="language-bash">make px4_sitl gazebo_iris
</code></pre>
<p><img src="https://i.postimg.cc/Gt1pv4Xw/gazebo.png"></p>
<h3 id="4视频记录">4.视频记录</h3>
<p>同时,我还将我的安装过程录制成了视频,请点击这里查看。</p><br><br>
来源:https://www.cnblogs.com/cporoske/p/11630426.html
頁:
[1]