ROS——无人机ROS仿真包 rotors_simulator 编译教程

蔚落 2022-11-20 09:42 541阅读 0赞

文章目录

    1. 安装依赖工具
    1. 源码下载编译
    • 2.1 创建ROS工程
    • 2.2 下载源码
    • 2.3 可能遇到的问题
      • 2.3.1 git失败
      • 2.3.2 缺少mav_msgs
      • 2.3.3 缺少某些包
      • 2.3.4 CMake Error
      • 2.3.5 python no found
      • 2.3.6 VMware运行Gazebo出错
    1. 测试
  • 参考资料

1. 安装依赖工具

安装wstool

  1. sudo apt install python3-wstool

2. 源码下载编译

2.1 创建ROS工程

  1. $ mkdir -p ~/UAV/src
  2. $ cd ~/UAV/src
  3. $ catkin_init_workspace # initialize your catkin workspace
  4. $ wstool init

2.2 下载源码

  1. git clone git@github.com:ethz-asl/rotors_simulator.git

2.3 可能遇到的问题

下载源码的过程中可能会出现如下的问题:

2.3.1 git失败

在这里插入图片描述
解决方法请参考我的另外一篇博客,点这里跳转。

2.3.2 缺少mav_msgs

在这里插入图片描述这个问题出现在noetic版本的ROS中,原因是该版本已经将这个ros包移除,解决办法是去mav_msgs官方github下载源码,然后放入工程的src/目录下,本文中放在~/UAV/src目录下。

  • mav_msgs官方github
  • CSDN下载

2.3.3 缺少某些包

在这里插入图片描述
解决方法请参考我的另外一篇博客,点这里跳转。

2.3.4 CMake Error

出现如下提示:

  1. CMake Error at rotors_simulator/rotors_gazebo_plugins/cmake/FindGlog.cmake:77 (MESSAGE):
  2. Failed to find glog - Could not find glog include directory, set
  3. GLOG_INCLUDE_DIR to directory containing glog/logging.h
  4. Call Stack (most recent call first):
  5. rotors_simulator/rotors_gazebo_plugins/cmake/FindGlog.cmake:103 (GLOG_REPORT_NOT_FOUND)
  6. rotors_simulator/rotors_gazebo_plugins/CMakeLists.txt:147 (find_package)
  7. -- Configuring incomplete, errors occurred!

解决方案

  1. sudo apt-get install libgoogle-glog-dev

解决问题后重新在工程目录下输入catkin_make即可

2.3.5 python no found

出现如下提示:

  1. [ 12%] Generating /home/lanx/Project/ROS/UAV/src/rotors_simulator/rotors_gazebo/models/iris/iris.sdf
  2. /bin/sh: 1: python: not found
  3. make[2]: *** [rotors_simulator/rotors_gazebo/CMakeFiles/sdf.dir/build.make:64: /home/lanx/Project/ROS/UAV/src/rotors_simulator/rotors_gazebo/models/iris/iris.sdf] Error 127

解决方案:
  这种情况的出现通常都是使用了较新版本的ubuntu,例如我用的ubuntu 20.04,系统自带的python版本就说python3.8,所以出现了问题。因此需要添加从python3到python的映射:

  1. sudo ln -s /usr/bin/python3 /usr/bin/python

2.3.6 VMware运行Gazebo出错

  这个问题主要出现在使用WMware虚拟机运行Gazebo的情况下,提示如下:

  1. VMware: vmw_ioctl_command error Invalid argument.”

解决方案:

  1. echo "export SVGA_VGPU10=0" >> ~/.bashrc

3. 测试

  记得每次出错后最好把工程目录下build文件夹内的文件都删除,然后重新catkin_make

  在工程目录下输入:

  1. source devel/setup.bash
  2. roslaunch rotors_gazebo mav_hovering_example.launch mav_name:=firefly world_name:=basic

运行结果如下图:
在这里插入图片描述

参考资料

  1. rotors_simulator的github账户

发表评论

表情:
评论列表 (有 0 条评论,541人围观)

还没有评论,来说两句吧...

相关阅读