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二次开发(一)MAVROS的安装)