21.gazebo introduction

In the previous section, we talked about the URDF model to describe the robot. We also loaded the URDF model in rviz and used some plug-ins to make it move in rviz to achieve simulation. But often this is not enough to meet our simulation needs. We hope that the robot simulation environment can be as similar as possible to the actual environment. Then, the gazebo described in this course can meet the above needs.

21.1 Overview

Gazebo is a free robot simulation software that provides high-fidelity physical simulation, a complete set of sensor models, and a very user- and program-friendly interaction method. Functions that can accurately and efficiently simulate robot work in complex indoor and outdoor environments. By loading the model, an operating environment similar to the actual operating environment is constructed, the robot is loaded into it, and the program is run to realize simulation.

21.1.1 Install gazebo

According to the installed ROS version, here is noetic as an example, input in the terminal,

21.1.2 Run gazebo

After the installation is complete, enter in the terminal,

image-20231027143156082

21.1.3 GUI interface introduction

21.2 Load urdf model in gazebo

To use urdf files with gazebo, you must add some tags specific for simulation to work properly with gazebo. For each robot model, each needs to add a tag. Let's take Yahboom's rosmaster-X3 as an example to explain how gazebo loads the urdf model.

Here are two function packages:

In addition, two function packages need to be installed. One is the function package for keyboard control nodes and terminal input.

The other is the turtlebot3-gazebo function package, which contains a set gazebo environment and terminal input.

Let’s start the program first to see the effect, enter in the terminal,

After starting, the following screen appears,

image-20231027171215162

Click [Camera] above and select [Orthographic].

image-20231027171355928

Then you can see the built environment, as shown below,

image-20231027171504425

Then start the keyboard control node,

image-20231027171632053

Press [i], [u], [o], [j], [l], [m], [,], [.] to control the movement of the car, and press the space bar to stop. Since the car is equipped with a camera and radar, we can also see the image data and radar data in rviz when it is started.

21.2.1 Launch file analysis

First look at the launched launch file,

Mainly focus on the following points:

Here is to start gazebo and then load the turtlebot3_world.world file, followed by some parameter settings, such as whether to use simulation time, etc. Generally, simulation time is used in gazebo, that is, use_sim_time is true.

Describe the urdf model that needs to be loaded. We will analyze the model here later.

Load the robot model in gazebo, the parameter is robot_description.

21.2.2 Model file analysis

File directory::~/ros_ws/src/yahboomcar_description/urdf/yahboomcar_X3.gazebo.urdf.xacro

Most of the tags of the file were mentioned in the previous lesson, so I won’t go into details here. The main ones are the following parts.

The yahboomcar_X3.gazebo.xacro file is loaded here. The directory of this file is,

Take a look at the contents of this file. This involves adding the tag and some plug-ins to each .

First look at the link of one of the wheels.

A necessary tag here is , which is used to set appearance parameters. The color set here is black, which is the color of the left rear wheel. The other parameters represent:

Let’s take a look at one of the plug-ins:

Add a plug-in here. The name of the plug-in file is libgazebo_ros_planar_move.so, which is included with a pair of . There are some parameter settings inside, such as this commandTopic, which is set to cmd_vel here. Plug-in files are saved in, /opt/ros/noetic/lib

image-20231027181110760

For additional information about the plug-in, please refer to the following URL:

gazebo_plugins - ROS Wiki

Let's take a look at some of the added sensors,

This is a sensor that adds a radar, including the radar-related parameters set in the tag, including the scanning angle, scanning depth, etc.;A plug-in libgazebo_ros_laser.so was also added later to set the radar topic and frameid.