Simulation is the imitation of a real-world process or system over time. Previously, we dealt with simple two-dimensional simulations. Very sophisticated three-dimensional systems can also be simulated. Simulation is a very important part of the ROS and robot development process as it allows the robot to be programmed and experimented with without having a physical robot. Robot simulation is an important tool for every robot builder. A well-developed simulator lets you quickly test algorithms, customize robots, and even train artificial intelligence. There are different types of simulators for various purposes. The Gazebo is a universal simulator for a wide variety of aims, from mobile robots to autonomous vehicles (AVs). However, AV simulators need powerful graphical engines to create a virtual environment as close to the real one. This is beyond the Gazebo power and you can find this feature in the new modern AV simulator such as SVL simulator or CARLA.
In the first step, we chose Gazebo as the simulator, and in the following focused on the SVL simulator as the main AV simulator. Gazebo offers the ability to accurately and efficiently simulate multiple robots in complex indoor and outdoor environments. The simulator has a full-featured physics engine, high-quality graphics, and good ROS compatibility. It is possible to simulate different motors and joints and different sensors, such as cameras and LiDARs. Gazebo simulator can be run from the command line (headless) or with a nice graphical user interface
The gazebo is already installed with the full ROS installation. But in case that you don't install ROS in the full mode you can use this automatic installation script for installing Gazebo:
$ curl -sSL http://get.gazebosim.org|incl
The Unified Robot Description Format (URDF) is a robotic model in XML format. The model primarily contains the coordinates frames (/tf). These help us find out what the different parts of the robot depend on. For example, we find out where the robot is located on the camera. Basically, we can define static tf and also joints inside the URDF file. They are also used by simulators. According to this, the simulator knows the shape of the parts of the robot and where the joints of the robot are. Making URDF files may seem difficult at first, but fortunately, many popular robot models are freely available on the Internet.
In order to modify the robot model both in the simulation and in Rviz, the robot's URDF file must be changed. This is necessary if we want to change the configuration of the robot, for example by adding sensors to the robot. Every element on the robot is assigned to a specific link. The relation between these links is defined under the joint tags.
Example URDF file:
<? xml version = "1.0"?> <robot name = "myRobot"> <link name = "base_link"> <visual> <geometry> <cylinder length = "0.6" radius = "0.2" /> </geometry> </visual> </link> <link name = "right_leg"> <visual> <geometry> <box size = "0.6 0.1 0.2" /> </geometry> </visual> </link> <joint name = "base_to_right_leg" type = "fixed"> <parent link = "base_link" /> <child link = "right_leg" /> </joint> </robot>