Skip to the content.

Simulating ROS Navigation in Gazebo

Simulated environment in which programmers are able to interact and experiment with 3D models at their fingertips. Being able to test algorithms, design robots, monitor systems of networks are essential to a succesful project. With Gazebo, a programmer is able to make use of an incredible physics engine, high-quality graphical interfaces and robust programming to design real tools before they are created.

This blog uses Ubuntu 18.04 with ROS Melodic and Gazebo 9. We assume that you have ROS and Gazebo already installed on your local system.

Installing Nvidia

This project makes use of Nvidia hardware to lower resource consumption and make the simulation run smoothly!

Nvidia Driver

sudo apt-get install nvidia-driver-470
sudo apt-get install nvidia-cuda-toolkit
nvcc --version

Runtime Container

distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
   && curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - \
   && curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker
nvidia-smi

Launch in Docker

Before we begin this tutorial, you can view the full project in docker!

Workspace and project

Gazebo Simulation Box

World files

A world in gazebo is just another word for a simulated environment for your experiments. Programmers can evaluate and test their robot in difficult or dangerous scenarios without any harm to the robot themselves.

Adding objects to the world

Spawn a Robot in Gazebo

Control the Robot

Monitor Robot

Rosnode

Rostopic

Rviz

RQT



All robot simulations make use of XML, especially the .urdf extension. The URDF (Universal Robot Description Format) model is a collection of XML files that describe a robot’s physical description. These files are used by ROS (Robot Operating System) to tell the computer what the robot actually looks like in real life.

Launch in Docker

For the customized simulation, you can view it in docker too!

Customize World

Earlier we worked with .world files to generate an environment for our robot. This time, we are going to customize it:

cd ~/sim_ws/src/navigation_robot

Build your own model

The more accurate you want your model to be, the more time you would need to spend on the design. The most standard way to go about creating one is placing a SDF file in the ~/.gazebo/models directory, however, we will be using our newly acquired knowledge on URDF in tandem with Xacro (XML Macro) to make shorter and clearer ROS descriptions.

cd ~/sim_ws/src/navigation_robot
mkdir urdf
cd urdf

Now, lets build a 4-wheel robot!

Great! We now have a blueprint for our components and some. Let’s put it together in another .xacro file!

touch robot.xacro

Now we have the description of our robot! All that remains is our .gazebo file, which will provide Gazebo with the properties we want our robot to have in the simulation!



With the current knowledge of ROS and Gazebo at your disposal, localization is within your grasp! Being able to send goals and automate path building is one of many amazing things we want a robot to be able to do. So, lets try it now!

Launch in Docker

For the localization simulation, its available in docker also!