其他分享
首页 > 其他分享> > 四旋翼无人机仿真之hector_quadrotor无人机(ROS + Gazebo)

四旋翼无人机仿真之hector_quadrotor无人机(ROS + Gazebo)

作者:互联网

这里写自定义目录标题

应用环境

ubuntu16.04 (虚拟机实体机下均可)
ROS kinetic
Gazebo为安装ROS时自带(本人为Gazebo 7)

hector_quadrotor 功能包结构简介

hector_quadrotor是ROS下开源的无人机仿真功能包,是tu-darmstadt-ros-pkg功能包的主要组成部分,该功能包是德国达姆施塔特工业大学在ROS上开源的无人机仿真功能包,自开源后便广泛应用于ROS+Gazebo环境下做无人机相关可视化仿真,是进行四旋翼无人机仿真的良好工具。其中hector_quadrotor有很多相关依赖包,均可在tu-darmstadt-ros-pkg中找到,感兴趣的同学可自行了解。

具体细节可参考网址:
tu-darmstadt-ros-pkg官方网址:http://wiki.ros.org/tu-darmstadt-ros-pkg
hector_quadrotor 官方网址:http://wiki.ros.org/hector_quadrotor

hector_quadrotor_description提供了通用的四旋翼URDF模型以及各种各样的传感器。
hector_quadrotor_gazebo包含了在Gazebo中运行四旋翼模型所需要的launch file以及依赖信息。
hector_quadrotor_teleop包含一个允许使用gamepad控制旋翼的节点。
hector_quadrotor_gazebo_plugins提供在Gazebo仿真环境中进行四旋翼仿真的所需的特定的plugins。

hector_quadrotor 功能包安装

1. 安装所需依赖库

安装ubuntu、ROS以及Gazebo
首先保证系统为ubuntu16.04,在ubuntu系统中安装ROS-kinetic版本(具体安装步骤在此不再赘述,可自行查阅相关安装教程,预计安装一小时)
ps:在安装ROS时,到最后的环节可能会遇见 sudo rosdep init错误的问题,具体解决方式可见:https://blog.csdn.net/nanianwochengshui/article/details/105702188

安装gazebo_ros_pkgs

sudo apt-get install ros-kinetic-gazebo-ros-pkgs ros-kinetic-gazebo-ros-control

安装 geographic_msgs

sudo apt-get install ros-kinetic-geographic-msgs

2. 下载、安装hector_quadrotor

配置工作空间

mkdir -p hector_quadrotor_tutorial/src
cd hector_quadrotor_tutorial

安装
Ubuntu系统kinetic版本的hector_quadrotor包可以从源:https://github.com/tu-darmstadt-ros-pkg/hector_quadrotor.git下载

wstool init src https://raw.github.com/tu-darmstadt-ros-pkg/hector_quadrotor/kinetic-devel/tutorials.rosinstall

回到catkin_ws工作空间hector_quadrotor_tutorial,输入catkin_make编译

ps:此处若没有安装wstool,则需要执行
sudo apt-get install python-wstool python-rosdep ninja-build
安装python-wstool。

当然,想必很多朋友们在通过链接下载的过程中,都会因为网络等一些问题,造成一定的下载问题,因此,本人针对这一问题,采用了在github中下载安装包再按地址拷贝进ubuntu相关工作空间的方式,具体如下:

下载hector_quadrotor安装包
https://github.com/tu-darmstadt-ros-pkg/hector_quadrotor
将安装包拷贝至工作空间下/src目录中,并执行catkin_make编译

正常情况下,编译成功
当然,也会出现如下问题,但大家不必担心,我已一一解决掉,耐心看如下文章:

(1)
在这里插入图片描述解决方式:
从源:https://github.com/ros-geographic-info/geographic_info.git下载,解压到hector_quadrotor_tutorial/src目录下,重新catkin_make.

(2)
在这里插入图片描述解决方式:
从源:https://github.com/ros-simulation/gazebo_ros_pkgs.git下载,同样解压到hector_quadrotor_tutorial/src目录下,进行catkin_make.

一般到这问题就基本解决了
没有?╮(╯_╰)╭再往下看~

如上述两个问题相似,显示缺少unique_id,此时从源https://github.com/ros-geographic-info/unique_identifier下载,同样解压到hector_quadrotor_tutorial/src目录下,进行catkin_make.

最后一个问题如图:
在这里插![在这里插入图片描述](https://www.icode9.com/i/ll/?i=58d90e57071942b99940ca57ef499c9e.png?,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA55m95aScYA==,size_20,color_FFFFFF,t_70,g_se,x_16入图片描述

通过阅读代码,可知错误原因是在类gazebo中没有找到成员函数SetWorldtoReferenceOrientation.
解决方式:
进入文件夹/usr/include/gazebo7/gazebo中,找到文件ImuSensor.hh,发现里面确实没有函数SetWorldtoReferenceOrientation,在里面添加该函数即可。
修改文件内部代码见https://github.com/SamFerwerda/Gazebo10-commits/blob/b33ac5982fb75cac894fa145f7268146d44e0724/gazebo/sensors/ImuSensor.hh

经过如上修改,基本大家可能会遇到的问题就已全部解决啦~撒花!!

最后在工作空间中编译catkin_make,等待十分钟左右~成功!!
在这里插入图片描述
最后,大家如果在此期间由安装包下载等问题,可以留言或私信,对您有所帮助的话,感谢您的点赞转发支持~大家加油!!

参考文章

https://blog.csdn.net/u013832707/article/details/53991921
https://blog.csdn.net/phenixlou/article/details/78518207
http://www.javashuo.com/article/p-cpjxryei-ku.html
[1]: https://blog.csdn.net/u013832707/article/details/53991921
[2]: https://blog.csdn.net/phenixlou/article/details/78518207
[3]: http://www.javashuo.com/article/p-cpjxryei-ku.html

标签:quadrotor,ROS,hector,https,无人机,ros,安装
来源: https://blog.csdn.net/weixin_48719406/article/details/122811274