MAVROS二次开发(一)MAVROS的安装

MAVROS二次开发

一、MAVROS的安装

1、参考网址

https://dev.px4.io/v1.10/en/ros/mavros_installation.html

https://github.com/mavlink/mavros/tree/master/mavros#installation

2、系统环境

  • Ubuntu 16.04LTS
  • ROS Kinetic

3、安装方式

  • 二进制
  • 源码

用MAVROS进行二次开发建议使用源码进行安装。

4、二进制方式进行安装

The ROS repository has binary packages for Ubuntu x86, amd64 (x86_64) and armhf (ARMv7). Kinetic also supports Debian Jessie amd64 and arm64 (ARMv8).
Use apt-get for installation:

sudo apt-get install ros-kinetic-mavros ros-kinetic-mavros-extras

运行 install_geographiclib_datasets.sh 脚本来安装GeographicLib datasets。

wget https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/install_geographiclib_datasets.sh
./install_geographiclib_datasets.sh

5、源码方式进行安装

创建ROS工作空间

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin init
wstool init src

安装所需ROS的python工具包

sudo apt-get install python-catkin-tools python-rosinstall-generator -y

While the package can be built using catkin_make the preferred method is using catkin_tools as it is a more versatile and “friendly” build tool.

如果是第一次使用wstool,需要去初始化

$ wstool init ~/catkin_ws/src

安装Mavlink

rosinstall_generator --rosdistro kinetic mavlink | tee /tmp/mavros.rosinstall

安装MAVROS

  • 稳定版本
rosinstall_generator --upstream mavros | tee -a /tmp/mavros.rosinstall
  • 最新版本
rosinstall_generator --upstream-development mavros | tee -a /tmp/mavros.rosinstall

如果想将所有的依赖项拉取到catkin_ws中,在上面的命令中添加‘–deps’即可,例如:rosinstall_generator --upstream mavros --deps | tee -a /tmp/mavros.rosinstall

合并源码至工作区,安装依赖

wstool merge -t src /tmp/mavros.rosinstall
wstool update -t src -j4
rosdep install --from-paths src --ignore-src -y

注意:-j后面最好是你的CPU线程数(不可大于CPU线程数,可能会有问题),要等到全部执行完毕,still active不是完成状态。

安装GeographicLib datasets

./src/mavros/mavros/scripts/install_geographiclib_datasets.sh

6、编译源码

catkin build

7、添加setup.bash至工作区

 #Needed or rosrun can't find nodes from this workspace.
source devel/setup.bash

未避免每次打开终端都要执行上述命令可以讲setup.bash添加到/.bashrc

echo "source ~/catkin_ws/devel/setup.bash" >> /.bashrc
### 安装 MAVROS 的前提条件 为了在 Ubuntu 20.04 上成功安装 MAVROS,需要先确保系统已经配置好 ROS (Robot Operating System) 和 PX4 环境。这通常涉及到系列依赖项的准备以及环境变量的设置[^1]。 ### 配置源和密钥 首先应当更新系统的软件包列表并添加必要的 GPG 密钥来验证下载的安全性: ```bash sudo apt update && sudo apt install curl gnupg2 lsb-release curl -s https://raw.githubusercontent.com/mavlink/mavros/master/mavros/scripts/apt_repo_add.sh | bash - ``` 上述命令会自动向 APT 源中加入 MAVLink/MAVROS 软件仓库,并导入相应的签名密钥以便后续可以安全地从该库获取所需资源。 ### 安装 MAVROS 当准备工作完成后,可以通过如下指令次性完成 MAVROS 及其常用插件的部署: ```bash sudo apt-get install ros-noetic-mavros ros-noetic-mavros-extras ``` 这里假设使用的 ROS 版本为 Noetic,在 Ubuntu 20.04 中这是默认支持的长期稳定版本之;如果使用其他版本,则需替换 `noetic` 关键字以匹配实际需求。 ### 编译自定义功能(可选) 对于那些希望进步定制化 MAVROS 行为或者利用最新特性而不局限于官方发布的二进制文件者来说,还可以考虑通过 Catkin 工具链来进行本地编译构建: #### 创建工作空间目录结构 ```bash mkdir -p ~/catkin_ws/src cd ~/catkin_ws/ wstool init src ``` #### 获取源码并初始化子模块 ```bash git clone --recursive https://github.com/mavlink/mavros.git src/mavros ``` #### 构建项目 ```bash rosdep install --from-paths src --ignore-src -r -y catkin_make_isolated --install source ~/.bashrc ``` 以上过程能够帮助开发者获得更灵活可控的应用程序实例,同时也便于调试与开发新功能。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值