当前位置:   article > 正文

基于Gazebo+ROS+PX4+QGC+深度相机实现无人机HITL半实物仿真_gazebo px4深度相机

gazebo px4深度相机

场景:Gazebo+ROS+PX4硬件(hitl模式)+QGC+Depth_camera,实现半实物仿真系统搭建

基于以上场景,实现无人机指控、导航、避障算法的仿真平台的搭建
官方硬件在环仿真关系图
PX4、Gazebo、QGC关系

一、连接PX4硬件,设置(hitl,硬件在环仿真模式),测试硬件在环仿真模式

官方参考链接: PX4 HITL SETUP

STEP1:将PX4硬件连接到QGC,设置HIL enabled

STEP2:编译Gazebo-classic上的仿真模块

(1)Build PX4 with Gazebo Classic (in order to build the Gazebo Classic plugins).

cd <Firmware_clone>
DONT_RUN=1 make px4_sitl_default gazebo-classic
  • 1
  • 2

(2)设置参数,打开Tools/simulation/gazebo-classic/sitl_gazebo-classic/models/iris_hitl/iris_hitl.sdf).找到文件的 mavlink_interface plugin 分区,将 serialEnabled 和 hil_mode 参数更改为 true。
注意:串口为ttyACM0,可以使用dmesg| grep "tty"进行验证
(3)配置环境变量

source Tools/simulation/gazebo-classic/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default

  • 1
  • 2

(4)启动Gazebo

gazebo Tools/simulation/gazebo-classic/sitl_gazebo-classic/worlds/hitl_iris.world
  • 1

(5)转发mavlink到其他电脑

mavlink-routerd -e 192.168.100.6:14550 127.0.0.1:14550
  • 1

最后一个为server,前面为client
以上为PX4+Gazebo半实物仿真系统,还没有添加ROS模块

二、通过ROS启动半实物仿真模型,启动depth_camera话题,启动mavros功能包

STEP1 启动gazebo_ros节点,加载世界模型

cd <PX4-Autopilot_clone>
source Tools/simulation/gazebo-classic/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/simulation/gazebo-classic/sitl_gazebo-classic

roslaunch gazebo_ros empty_world.launch world_name:=$(pwd)/Tools/simulation/gazebo-classic/sitl_gazebo-classic/worlds/empty.world
  • 1
  • 2
  • 3
  • 4
  • 5

STEP2 启动无人机模型,iris_hitl_depth_camera,为iris_hitl加装了深度相机的模型,会输出深度和rgb话题

<?xml version="1.0" ?>
<sdf version="1.5">
  <model name='iris_hitl_depth_camera'>
    <include>
      <uri>model://iris_hitl</uri>
    </include>

    <include>
      <uri>model://depth_camera</uri>
      <pose>0.1 0 0 0 0 0</pose>
    </include>
    <joint name="depth_camera_joint" type="revolute">
      <child>depth_camera::link</child>
      <parent>iris::base_link</parent>
      <axis>
        <xyz>0 0 1</xyz>
        <limit>
          <upper>0</upper>
          <lower>0</lower>
        </limit>
      </axis>
    </joint>

  </model>
</sdf>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
rosrun gazebo_ros spawn_model -sdf -file $(pwd)/Tools/simulation/gazebo-classic/sitl_gazebo-classic/models/iris/iris_hitl_depth_camera.sdf -model iris -x 0 -y 0 -z 0 -R 0 -P 0 -Y 0
  • 1

STEP3 开启MAVROS节点,将mavlink消息转发为ROS节点

roslaunch mavros px4.launch fcu_url:="udp://:14540@127.0.0.1:14557"
  • 1

以上便启动了基于ROS+gazebo+PX4的半实物仿真过程,也可以通过以下launch文件一起启动,不过原始脚本是启动的SITL软件在环仿真,可以修改其iris模型,添加hitl描述,同时不需运行sitl节点

cd <Firmware_clone>
source Tools/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/sitl_gazebo
roslaunch px4 mavros_posix_sitl.launch
  • 1
  • 2
  • 3
  • 4
  • 5

以下就是同时启动PX4 HITL+GAZEBO+ROS+RVIZ深度图+QGC的画面,有问题可留言探讨

仿真模型

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/647680
推荐阅读
相关标签
  

闽ICP备14008679号