Linux系统ubuntu20.04 无人机PX4 开发环境搭建(失败率很低)

Linux系统ubuntu20.04 无人机PX4 开发环境搭建

  • PX4固件下载
  • 开发环境搭建
  • MAVROS安装
  • 安装地面站QGC

PX4固件下载

PX4的源码处于GitHub,因为众所周知的原因git clone经常失败,此处从Gitee获取PX4源码和依赖模块。

git clone https://gitee.com/voima/PX4-Autopilot.git

正克隆到 ‘PX4-Autopilot’…
remote: Enumerating objects: 454209, done.
remote: Total 454209 (delta 0), reused 0 (delta 0), pack-reused 454209
接收对象中: 100% (454209/454209), 215.48 MiB | 2.32 MiB/s, 完成.
处理 delta 中: 100% (334699/334699), 完成.
在这里插入图片描述在这里插入图片描述

使用cd命令切换到 px4项目文件目录:

cd ~/PX4-Autopilot

使用以下命令切换版本,以V1.14.0为例:

git checkout v1.14.0 #切换到1.14.0分支,当然也可以尝试其他版本

因为PX4的完整项目是嵌套子模块存储的,以上命令只下载了px4的基本代码,所以我们要进行子模块的下载,运行下列命令:

 git submodule update --init --recursive # 在~/PX4-Autopilot目录下执行

以上命令中,submodule是子模块的意思, --init 选项会初始化,并注册子模块的地址,–recursive选项会递归克隆子模块。

此更新的链接来源于~/PX4-Autopilot/.gitmodules(注意是隐藏文件)

将文件打开,粘贴到下面,可以看到里面都github的地址,直接用上面的命令,会很难成功

[submodule "src/modules/mavlink/mavlink"]
	path = src/modules/mavlink/mavlink
	url = https://github.com/mavlink/mavlink.git
	branch = master
[submodule "src/drivers/uavcan/libuavcan"]
	path = src/drivers/uavcan/libuavcan
	url = https://github.com/dronecan/libuavcan.git
	branch = main
[submodule "Tools/simulation/jmavsim/jMAVSim"]
	path = Tools/simulation/jmavsim/jMAVSim
	url = https://github.com/PX4/jMAVSim.git
	branch = main
[submodule "Tools/simulation/gazebo-classic/sitl_gazebo-classic"]
	path = Tools/simulation/gazebo-classic/sitl_gazebo-classic
	url = https://github.com/PX4/PX4-SITL_gazebo-classic.git
	branch = main
[submodule "src/drivers/gps/devices"]
	path = src/drivers/gps/devices
	url = https://github.com/PX4/PX4-GPSDrivers.git
	branch = main
[submodule "platforms/nuttx/NuttX/nuttx"]
	path = platforms/nuttx/NuttX/nuttx
	url = https://github.com/PX4/NuttX.git
	branch = px4_firmware_nuttx-10.3.0+-v1.14
[submodule "platforms/nuttx/NuttX/apps"]
	path = platforms/nuttx/NuttX/apps
	url = https://github.com/PX4/NuttX-apps.git
	branch = px4_firmware_nuttx-10.3.0+
[submodule "Tools/flightgear_bridge"]
	path = Tools/simulation/flightgear/flightgear_bridge
	url = https://github.com/PX4/PX4-FlightGear-Bridge.git
[submodule "Tools/simulation/jsbsim/jsbsim_bridge"]
	path = Tools/simulation/jsbsim/jsbsim_bridge
	url = https://github.com/PX4/px4-jsbsim-bridge.git
[submodule "src/drivers/cyphal/libcanard"]
	path = src/drivers/cyphal/libcanard
	url = https://github.com/opencyphal/libcanard.git
[submodule "src/drivers/cyphal/public_regulated_data_types"]
	path = src/drivers/cyphal/public_regulated_data_types
	url = https://github.com/opencyphal/public_regulated_data_types.git
[submodule "src/drivers/cyphal/legacy_data_types"]
	path = src/drivers/cyphal/legacy_data_types
	url = https://github.com/PX4/public_regulated_data_types.git
	branch = legacy
[submodule "src/lib/crypto/monocypher"]
	path = src/lib/crypto/monocypher
	url = https://github.com/PX4/Monocypher.git
	branch = px4
[submodule "src/lib/events/libevents"]
	path = src/lib/events/libevents
	url = https://github.com/mavlink/libevents.git
	branch = main
[submodule "src/lib/crypto/libtomcrypt"]
	path = src/lib/crypto/libtomcrypt
	url = https://github.com/PX4/libtomcrypt.git
	branch = px4
[submodule "src/lib/crypto/libtommath"]
	path = src/lib/crypto/libtommath
	url = https://github.com/PX4/libtommath.git
	branch = px4
[submodule "src/modules/uxrce_dds_client/Micro-XRCE-DDS-Client"]
	path = src/modules/uxrce_dds_client/Micro-XRCE-DDS-Client
	url = https://github.com/PX4/Micro-XRCE-DDS-Client.git
	branch = px4

将其更新为 gitee 的地址,已经整理测试好了,直接替换掉文件的内容即可

[submodule "src/modules/mavlink/mavlink"]
	path = src/modules/mavlink/mavlink
	url = https://gitee.com/wtp95/mavlink.git
	branch = master
	
[submodule "Tools/flightgear_bridge"]
	path = Tools/simulation/flightgear/flightgear_bridge
	url = https://gitee.com/seokhb/PX4-FlightGear-Bridge.git
	
[submodule "Tools/simulation/gazebo-classic/sitl_gazebo-classic"]
	path = Tools/simulation/gazebo-classic/sitl_gazebo-classic
	url = https://gitee.com/seokhb/PX4-SITL_gazebo-classic.git
	branch = main
	
[submodule "Tools/simulation/jmavsim/jMAVSim"]
	path = Tools/simulation/jmavsim/jMAVSim
	url = https://gitee.com/seokhb/jMAVSim.git
	branch = main
	
[submodule "Tools/simulation/jsbsim/jsbsim_bridge"]
	path = Tools/simulation/jsbsim/jsbsim_bridge
	url = https://gitee.com/seokhb/px4-jsbsim-bridge.git
	
[submodule "platforms/nuttx/NuttX/apps"]
	path = platforms/nuttx/NuttX/apps
	url = https://gitee.com/seokhb/NuttX-apps.git
	branch = px4_firmware_nuttx-10.3.0+
	
[submodule "platforms/nuttx/NuttX/nuttx"]
	path = platforms/nuttx/NuttX/nuttx
	url = https://gitee.com/seokhb/NuttX.git
	branch = px4_firmware_nuttx-10.3.0+-v1.14

[submodule "src/drivers/cyphal/public_regulated_data_types"]
	path = src/drivers/cyphal/public_regulated_data_types
	url = https://gitee.com/seokhb/public_regulated_data_types.git
	
[submodule "src/drivers/cyphal/legacy_data_types"]
	path = src/drivers/cyphal/legacy_data_types
	url = https://gitee.com/jiyuanwangxs/legacy_data_types.git
	branch = legacy

[submodule "src/drivers/cyphal/libcanard"]
	path = src/drivers/cyphal/libcanard
	url = https://gitee.com/seokhb/libcanard.git
	
[submodule "src/drivers/gps/devices"]
	path = src/drivers/gps/devices
	url = https://gitee.com/seokhb/PX4-GPSDrivers.git
	branch = main
	
[submodule "src/drivers/uavcan/libuavcan"]
	path = src/drivers/uavcan/libuavcan
	url = https://gitee.com/seokhb/libuavcan.git
	
[submodule "src/lib/crypto/libtomcrypt"]
	path = src/lib/crypto/libtomcrypt
	url = https://gitee.com/seokhb/libtomcrypt.git
	branch = px4
	
[submodule "src/lib/crypto/libtommath"]
	path = src/lib/crypto/libtommath
	url = https://gitee.com/seokhb/libtommath.git
	branch = px4
	
[submodule "src/lib/crypto/monocypher"]
	path = src/lib/crypto/monocypher
	url = https://gitee.com/seokhb/Monocypher.git
	branch = px4
	
[submodule "src/lib/events/libevents"]
	path = src/lib/events/libevents
	url = https://gitee.com/seokhb/libevents.git
	branch = main

[submodule "src/modules/uxrce_dds_client/Micro-XRCE-DDS-Client"]
	path = src/modules/uxrce_dds_client/Micro-XRCE-DDS-Client
	url = https://gitee.com/seokhb/Micro-XRCE-DDS-Client.git
	branch = px4

然后执行下面的命令,就可以

git submodule update --init --recursive

有的子模块还是走的github,失败了就多试几次,直到用上面命令不再下载东西了就可以了
在这里插入图片描述

开发环境搭建

PX4的完整代码已经下载完了,接下来就是配置开发环境。PX4源码中已经提供了开发环境配置的脚本,在/PX4-Autopilot/Tools/setup目录中,该目录下的文件如下:
在这里插入图片描述
可以看到里面有Arch/Macos和ubuntu系统的配置脚本。
ubuntu系统,运行ubuntu.sh文件
这是一个脚本文件,里面是一些bash命令,可以理解为一系列下载px4开发环境的代码。在上图界面右键选择在终端打开,使用下列命令运行:

bash ubuntu.sh

如果出现很多错误,和镜像源有关,那么则手动安装一些模块

sudo apt install python3-pip
pip3 install kconfiglib
pip3 install --user jinja2
pip3 install --user jsonschema
sudo apt-get update
sudo apt-get install libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev

然后需配置~/.bashrc文件,打开该文件,在底部添加如下内容,保存。

# >>> PX4 initialize >>>
source ~/PX4-Autopilot/Tools/simulation/gazebo-classic/setup_gazebo.bash ~/PX4-Autopilot ~/PX4-Autopilot/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4-Autopilot
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4-Autopilot/Tools/simulation/gazebo-classic/sitl_gazebo-classic
# <<< PX4 initialize <<<

然后进行编译

cd ~/PX4-Autopilot  # 也可以 roscd px4
make px4_sitl_default gazebo
```cd ~/PX4-Autopilot 
如果出现下面的错误,一直在等待master

> [Msg] Waiting for master.
[Err] [ConnectionManager.cc:121] Failed to connect to master in 30 seconds.
[Err] [gazebo_shared.cc:78] Unable to initialize transport.
[Err] [gazebo_client.cc:56] Unable to setup Gazebo
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/db19e2b420d54580b3a52f053d642fbf.png)

则需要在.bashrc文件的最后一行加入

```c
source /opt/ros/noetic/setup.bash

然后再启动

终端出现如下,gazebo启动,中间有个小飞机,则代表开发环境搭建成功
在这里插入图片描述
在这里插入图片描述

MAVROS安装

安装geographiclib数据库(GeographicLib是一个用于解决地理坐标转换、大地测量(geodesy)和地图投影等问题的库,广泛用于航空航天和GIS(地理信息系统)领域)

安装MAVROS

sudo apt install ros-noetic-mavros ros-noetic-mavros-extras

准备解压 …/ros-noetic-mavros_1.18.0-1focal.20240304.150259_amd64.deb …
正在解压 ros-noetic-mavros (1.18.0-1focal.20240304.150259) 并覆盖 (1.15.0-1focal
.20230216.003459) …
准备解压 …/ros-noetic-mavros-extras_1.18.0-1focal.20240304.151354_amd64.deb .

正在解压 ros-noetic-mavros-extras (1.18.0-1focal.20240304.151354) 并覆盖 (1.15.0
-1focal.20230216.014052) …
正在设置 ros-noetic-mavros (1.18.0-1focal.20240304.150259) …
正在设置 ros-noetic-mavros-extras (1.18.0-1focal.20240304.151354) …
在这里插入图片描述

安装geographiclib数据库(GeographicLib是一个用于解决地理坐标转换、大地测量(geodesy)和地图投影等问题的库,广泛用于航空航天和GIS(地理信息系统)领域)

wget https://gitee.com/robin_shaun/XTDrone/raw/master/sitl_config/mavros/install_geographiclib_datasets.sh
sudo chmod a+x ./install_geographiclib_datasets.sh
sudo ./install_geographiclib_datasets.sh 

检查MAVROS是否安装成功可输入如下命令:

roslaunch px4 mavros_posix_sitl.launch

新打开一个终端,输入:

rostopic echo mavros/state

header:
seq: 27
stamp:
secs: 27
nsecs: 524000000
frame_id: ‘’
connected: True
armed: False
guided: True
manual_input: False
mode: “AUTO.LOITER”
system_status: 3
在这里插入图片描述
看到connected为True 则 MAVROS安装成功

安装地面站QGC

首先执行下面指令

sudo usermod -a -G dialout $USER
sudo apt-get remove modemmanager -y

安装一些依赖库

sudo apt install gstreamer1.0-plugins-bad gstreamer1.0-libav gstreamer1.0-gl -y
sudo apt install libfuse2 -y
sudo apt install libxcb-xinerama0 libxkbcommon-x11-0 libxcb-cursor0 -y

然后系统登出再登入,确定改变了用户权限

下面开始安装QGC
下载QGroundControl.AppImage,下载链接
将该文件移动到主目录下面
通过指令更改权限,和运行

chmod +x ./QGroundControl.AppImage
./QGroundControl.AppImage  

然后会运行QGC的软件
在这里插入图片描述

之后双击 QGroundControl.AppImage 图标也可以运行该软件

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/727590.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

使用 Python 中的美丽汤进行网络数据解析的完整指南

Beautiful Soup 是一个广泛使用的 Python 库&#xff0c;在数据提取方面发挥着重要作用。它为解析 HTML 和 XML 文档提供了强大的工具&#xff0c;使从网页中轻松提取有价值的数据成为可能。该库简化了处理互联网上非结构化内容的复杂过程&#xff0c;使您可以将原始网页数据转…

【nginx】 nginx核心功能

【nginx】 nginx核心功能 1.nginx核心功能 1. 反向代理 2. 负载均衡 3. 动静分离 4. nginx的高可用2. 反向代理 正向代理: 该服务器代理的是客户端&#xff0c;对于服务器来说&#xff0c;不知道真实客户端的ip。比如: 翻墙软件。 访问国外的服务器---使用了翻墙软件----对…

2024年【R1快开门式压力容器操作】考试及R1快开门式压力容器操作考试内容

题库来源&#xff1a;安全生产模拟考试一点通公众号小程序 2024年R1快开门式压力容器操作考试为正在备考R1快开门式压力容器操作操作证的学员准备的理论考试专题&#xff0c;每个月更新的R1快开门式压力容器操作考试内容祝您顺利通过R1快开门式压力容器操作考试。 1、【多选题…

开源技术:在线教育系统源码及教育培训APP开发指南

本篇文章&#xff0c;小编将探讨如何利用开源技术开发在线教育系统及教育培训APP&#xff0c;旨在为有志于此的开发者提供全面的指导和实践建议。 一、在线教育系统的基本构架 1.1架构设计 包括前端、后端和数据库三个主要部分。 1.2前端技术 在前端开发中&#xff0c;HTML…

【我是产品经理_注册安全分析报告】

前言 由于网站注册入口容易被黑客攻击&#xff0c;存在如下安全问题&#xff1a; 暴力破解密码&#xff0c;造成用户信息泄露短信盗刷的安全问题&#xff0c;影响业务及导致用户投诉带来经济损失&#xff0c;尤其是后付费客户&#xff0c;风险巨大&#xff0c;造成亏损无底洞 …

论文学习 Learning Robust Representations via Multi-View Information Bottleneck

Code available at https://github.com/mfederici/Multi-View-Information-Bottleneck 摘要&#xff1a;信息瓶颈原理为表示学习提供了一种信息论方法&#xff0c;通过训练编码器保留与预测标签相关的所有信息&#xff0c;同时最小化表示中其他多余信息的数量。然而&#xff0…

HCIA-速查-ENSP模拟器2步清空配置

需求&#xff1a;清空模拟器配置 清空当前图中配置 步骤1&#xff1a;reset saved-configuration 后输入y确认 步骤2&#xff1a;reboot后输入n否认再输入y确认 验证已经清空配置

QT利用QGraphicsDropShadowEffect效果及自定义按钮来实现一个炫酷键盘

1、效果 2、核心代码 #include "widget.h" #include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent<

阿里云 邮件系统DNS域名解析 搭配 postfix+dovecot 邮件服务器

1 创建邮箱域名A记录(一般邮箱客户端&#xff0c;增加pop,imap,stmp 3条记录) 登录阿里云控制台--云解析DNS 2 MX记录 3 SPF记录

chatgpt: linux 下用纯c 编写ui

在Linux下用纯C语言编写用户界面&#xff08;UI&#xff09;&#xff0c;通常会使用GTK或Xlib。GTK是一个更高级的库&#xff0c;提供了丰富的控件和功能&#xff0c;而Xlib则是一个更底层的库&#xff0c;提供了直接操作X Window系统的功能。 下面是一个使用GTK在Linux上创建…

R语言dplyr统计指定列里面种类个数和比例

输入数据框&#xff1a;dfuorf&#xff0c;Type列有uORF和overlpaORF两种类型 dfuorf1 <- dfuorf %>%group_by(Type) %>% summarise(Countn()) %>% mutate(percentCount/sum(Count)) %>% mutate(percent1 (paste0(round((Count/sum(Count)), 2)*100,"%&…

【因果推断python】46_估计量2

目录 连续型干预变量案例 非线性处理效果 关键思想 连续型干预变量案例 目标转换方法的另一个明显缺点是它仅适用于离散或二元处理。这是你在因果推理文献中经常看到的东西。大多数研究都是针对二元干预案例进行的&#xff0c;但您找不到很多关于连续干预的研究。这让我很困…

【深度学习】GELU激活函数是什么?

torch.nn.GELU 模块在 PyTorch 中实现了高斯误差线性单元&#xff08;GELU&#xff09;激活函数。GELU 被用于许多深度学习模型中&#xff0c;包括Transformer&#xff0c;因为它相比传统的 ReLU&#xff08;整流线性单元&#xff09;函数能够更好地近似神经元的真实激活行为。…

ARM64汇编0B - 函数调用约定

建议先看《CSAPP》的3.7节&#xff0c;讲的很细。我们这里就直接看例子来分析了。 例子 static int func(int a, int b, int c, int d, int e, int f, int g, int h, int i) {printf("%s\n", "add all");int x a b;return a b c d e f g h i; …

Faiss:选择合适的索引Index

向量相似性搜索彻底改变了搜索领域。它允许我们高效地检索从GIF到文章等各种媒体&#xff0c;即使在处理十亿级别数据集时&#xff0c;也能在亚秒级时间内提供令人印象深刻的准确性。 然而&#xff0c;这种灵活性也带来了一个问题&#xff1a;如何知道哪种索引大小最适合我们的…

2-11 基于matlab的BP-Adaboost的强分类器分类预测

基于matlab的BP-Adaboost的强分类器分类预测&#xff0c;Adaboost是一种迭代分类算法&#xff0c;其在同一训练集采用不同方法训练不同分类器&#xff08;弱分类器&#xff09;&#xff0c;并根据弱分类器的误差分配不同权重&#xff0c;然后将这些弱分类器组合成一个更强的最终…

check python checking for Python executable “python2“ in the PATH

背景&#xff1a; mac电脑升级后重新拉取老项目后安装node_module 和启动项目报错 gyp info using node-gyp3.8.0 gyp info using node14.18.0 | darwin | x64 gyp verb command rebuild [] gyp verb command clean [] gyp verb clean removing "build" directory …

Python基础教程(二十六):对接MongoDB

&#x1f49d;&#x1f49d;&#x1f49d;首先&#xff0c;欢迎各位来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里不仅可以有所收获&#xff0c;同时也能感受到一份轻松欢乐的氛围&#xff0c;祝你生活愉快&#xff01; &#x1f49d;&#x1f49…

视听分割相关论文阅读

1. End-to-End Referring Video Object Segmentation with Multimodal Transformers RVOS&#xff08;视频中的参考对象分割&#xff09;比RIS&#xff08;图像中的参考对象分割&#xff09;要困难得多&#xff0c;因为指代动作的文本表达通常无法从单个静态帧中正确推断出来。…

Web3 学习

之前学习 web3&#xff0c;走了不少弯路&#xff0c;最近看到了 hackquest&#xff0c;重新刷了一遍以太坊基础&#xff0c;感觉非常nice&#xff0c;而且完全免费&#xff0c;有需要的可以试试&#xff0c;链接hackquest.io。