06-1-Gazebo仿真

小芽科技 2022-07-26 11:46:08
Categories: Tags:

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

模拟仿真

 Read more about TurtleBot3 Simulation

TurtleBot3 supports simulation development environment that can be programmed and developed with a virtual robot in the simulation. There are two development environments to do this, one is using a fake node with 3D visualization tool RViz, and the other is using the 3D robot simulator Gazebo.

  • The fake node is suitable for testing with the robot model and movement, but it does not support sensors.
  • If you need to perform SLAM or Navigation, Gazebo would be a feasible solution as it supports sensors such as IMU, LDS, and camera.

In this instruction, Gazebo will be mainly introduced which is most widely used among ROS developers.

6.1 Gazebo 仿真

电子手册中的内容可以在不事先通知的情况下进行更新,视频内容可能已经过时。

本Gazebo模拟使用ROS Gazebo包,因此,在运行本指令前,必须安装适合ROS1 Kinetic的Gazebo版本。

6.1.1 安装模拟仿真包

TurtleBot3 Simulation Package需要turtlebot3turtlebot3_msgs软件包作为前提条件。没有这些先决条件的软件包,模拟程序无法启动。
如果你没有安装所需的软件包和附属软件包,请按照PC Setup的说明进行操作。

1
2
3
$ cd ~/catkin_ws/src/
$ git clone -b kinetic-devel https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
$ cd ~/catkin_ws && catkin_make

6.1.2 运行仿真环境

  1. 为TurtleBot3准备了三种模拟环境。请从这些环境中选择一个来启动Gazebo。

    在启动新的仿真环境时,请确保完全终止其他仿真环境。

  2. Empty World

    1
    2
    $ export TURTLEBOT3_MODEL=burger
    $ roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch
  3. TurtleBot3 World

    1
    2
    $ export TURTLEBOT3_MODEL=waffle
    $ roslaunch turtlebot3_gazebo turtlebot3_world.launch
  4. TurtleBot3 House

    1
    2
    $ export TURTLEBOT3_MODEL=waffle_pi
    $ roslaunch turtlebot3_gazebo turtlebot3_house.launch

注意:+如果TurtleBot3 House是第一次启动,下载地图可能需要超过几分钟的时间,这取决于网络状态。

6.1.3 操作 TurtleBot3

为了用键盘对TurtleBot3进行远程操作,在一个新的终端窗口中用以下命令启动远程操作节点。

1
$ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

 Read more about How to run Autonomous Collision Avoidance

A simple collision avoidance node is prepared which keeps certain distance from obstacles and make turns to avoid collision.
In order to autonomously drive a TurtleBot3 in the TurtleBot3 world, please follow the instruction below.

  1. Terminate the turtlebot3_teleop_key node by entering Ctrl + C to the terminal that runs the teleop node.

  2. Enter the below command to the terminal.

    $ roslaunch turtlebot3_gazebo turtlebot3_simulation.launch
    

 Read more about How to visualize Simulation data(RViz)

RViz visualizes published topics while simulation is running. You can launch RViz in a new terminal window by entering below command.

$ roslaunch turtlebot3_gazebo turtlebot3_gazebo_rviz.launch