PixhawkPX4开发环境搭建Ubuntu-1804

14次阅读

共计 2144 个字符,预计需要花费 6 分钟才能阅读完成。

本文主要记录了 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. 等待安装完成

安装完成后,会在终端提示重启电脑。

安装完成后,你可以通过检查 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.win…

复制到浏览器进行下载,下载完成后,要参照着 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

4. 视频记录

同时,我还将我的安装过程录制成了视频,请点击这里查看。

正文完
 0