06-5-独立运行Gazebo仿真

小芽科技 2022-07-26 11:51:23
Categories: Tags:

本文档由北京小芽科技翻译,原文来自于ROBOTIS官方技术文档

6.5 单独运行 Gazebo 仿真

注意。本教程只为那些想在没有ROS的情况下模拟TurtleBot3的用户开发。然而,我们强烈建议在ROS上运行模拟。

  1. 为 Gazebo7安装相关库。

    1
    $ sudo apt-get install libgazebo7-dev
  2. 从 Github上下载源码。

    1
    $ git clone https://github.com/ROBOTIS-GIT/turtlebot3_gazebo_plugin
  3. .bashrc文件中添加Gazebo 插件路径

    1
    $ nano ~/.bashrc

    NOTE: turtlebot3_gazebo_plugin path = ~/turtlebot3_gazebo_plugin

    1
    2
    export GAZEBO_PLUGIN_PATH=$GAZEBO_PLUGIN_PATH:${turtlebot3_gazebo_plugin path}/build
    export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:${turtlebot3_gazebo_plugin path}/models
  4. Make 和 Build

    1
    2
    3
    4
    5
    $ cd ${turtlebot3_gazebo_plugin path}
    $ mkdir build
    $ cd build
    $ cmake ..
    $ make
  5. 运行 Gazebo Plugin.

    将**${TB3_MODEL}**替换为你想使用的TurtleBot3模型。burger, waffle, waffle_pi.

    1
    2
    $ cd ${turtlebot3_gazebo_plugin}
    $ gazebo worlds/turtlebot3_${TB3_MODEL}.world

img
img

  1. 键盘远程控制

    1
    2
    3
    4
    5
    w - set linear velocity up
    x - set linear velocity down
    d - set angular velocity up
    a - set angular velocity down
    s - set all velocity to zero
  2. 订阅主题命令

    • 显示主题

      1
      $ gz topic -l
    • 订阅扫描数据

      1
      $ gz topic -e /gazebo/default/user/turtlebot3_${TB3_MODEL}/lidar/hls_lfcd_lds/scan
    • 订阅图像数据

      • 来自 Waffle

        1
        $ gz topic -e /gazebo/default/user/turtlebot3_waffle/image/intel_realsense_r200/image
      • 来自 Waffle Pi

        1
        $ gz topic -e /gazebo/default/user/turtlebot3_waffle_pi/image/raspberry_pi_cam/image
  3. 启动监听

    1
    2
    $ cd ${turtlebot3_gazebo_plugin}/build
    $ ./lidar_listener ${TB3_MODEL}
  4. 打开一个新的终端窗口,输入以下命令。

    1
    2
    $ cd ${turtlebot3_gazebo_plugin}/build
    $ ./image_listener ${TB3_MODEL}