Reader small image

You're reading from  Hands-On ROS for Robotics Programming

Product typeBook
Published inFeb 2020
PublisherPackt
ISBN-139781838551308
Edition1st Edition
Tools
Concepts
Right arrow
Author (1)
Bernardo Ronquillo Japón
Bernardo Ronquillo Japón
author image
Bernardo Ronquillo Japón

Bernardo Ronquillo Japn is an Internet of Things (IoT) and robotics expert who has worked for top technology companies since 1995, including Instituto de Astrofsica de Canarias, Gran Telescopio Canarias, Altran, and Alestis Aerospace. Using his skills and experience, he founded The Robot Academy, where he develops open source hardware and software solutions for engineers and makers: Social Robot IO (2015), for the stimulation of children with autistic spectrum disorder; Robot JUS (2016), which helps engineers get deeper technical insights with the Robot Operating System (ROS) when using low-complexity hardware; and IIoT All-in-One (2018) as an industrial IoT training package for assisting companies in their digital transformation process.
Read more about Bernardo Ronquillo Japón

Right arrow

Simulating Robot Behavior with Gazebo

This chapter deals with the dynamic simulation of a robot, which, conceptually, is a better approach to examining the actual behavior of the robot rather than just using software. Rigid body mechanics, including mass and inertia, friction, damping, motor controllers, sensor detection properties, noise signals, and every aspect of the robot and the environment that can be retained in a model with reasonable accuracy is much less expensive when replicated in a simulator than if you tried to do this with physical hardware.

By reading this chapter, you will learn how to plug the digital definition of your robot (the URDF file) into the simulation environment of Gazebo, which is powered with a physics engine that's able to emulate realistic behaviors. You will also extend your training by checking and testing the digital robot so that its...

Technical requirements

The code files for this chapter can be found at https://github.com/PacktPublishing/Hands-On-ROS-for-Robotics-Programming/tree/master/Chapter5_Gazebo_basics.

By completing the previous chapter, you should have cloned this book's code repository into the home folder of your laptop. In case you didn't, we'll go over this now. From a Terminal on your laptop, clone the repository into your home folder, like so:

$ cd ~
$ git clone https://github.com/PacktPublishing/Hands-On-ROS-for-Robotics-Programming

Next, we copy the code for this chapter to the ROS workspace. This way, you will have a cleaner ROS environment:

$ cp -R ~/Hands-On-ROS-for-Robotics-Programming/Chapter5_Gazebo_basics ~/catkin_ws/src

This chapter contains a new ROS package called gazebo_basics, so rebuild the workspace so that it is known to your ROS environment:

$ cd ~/catkin_ws
...

Getting started with the Gazebo simulator

Let's go through a quick tour so that you have a clear understanding of what you can expect when implementing a dynamic simulation for GoPiGo3. Gazebo is an open source 3D robotics simulator and includes an ODE physics engine and OpenGL rendering, and supports code integration for closed-loop control in robot drives—that is, sensor simulation and actuator control. There are two new concepts within this definition. Let's explain each one:

  • Open Dynamics Engine (ODE), a physics engine written in C/C++ that includes two main components: rigid-body dynamics simulation and collision detection (https://www.ode.org/).
  • Open Graphics Library (OpenGL), which is both a cross-language and cross-platform API for rendering 2D and 3D vector graphics. This API is typically used to interact with a GPU in order to achieve hardware-accelerated...

Making modifications to the robot URDF

URDF, as we explained in the previous chapter, stands for Unified Robot Description Format and has an XML-compliant syntax to simulate the visual properties of a robot. This format, fitting the scope it was conceived for, does not model some of the characteristics that are needed for a dynamic simulation. More precisely, it cannot specify the following:

  • The pose of the robot itself within a world.
  • Joint loops (parallel linkages).
  • Friction and other properties.
  • Things that are not robots, such as lights, height maps, and so on.

For such reasons, an evolved XML format called Simulation Description Format (SDF) started its development as part of the Gazebo robot simulator. SDF allows us to describe objects to the environments for robot simulators, visualization, and control. Over the years, SDF has become a stable, robust, and extensible format...

Verifying a Gazebo model and viewing the URDF

Once the SDF definition has been completed in the gopigo.urdf file, you should perform some checks to ensure that the file can be read by Gazebo. To do so, navigate to the folder where the model resides:

$ roscd gazebo_basics/urdf

The roscd command is a very useful ROS command that's equivalent to the Linux cd command, but specifies the paths that are relative to a given package. It's also easier to use because all you have to do is provide the name of the package that you want to move to the Terminal. The first part, gazebo_basics, retrieves the absolute path of the package, as well as the second part of the folder or subfolder path you want to show. This ROS command, as well as other useful ones, will be covered in detail in the next chapter, under the Shell commands subsection.

Use the following two commands to print and...

Moving your model around

Once the simulation has been launched, you can use the interaction icons in the Gazebo window. For example, you can play with the rotation tool of the environment toolbar to see how gravity affects the cone when you move it from its point of equilibrium:

Also, you can access the Joints panel (drag from the right border of the Gazebo window if it is not visible), select the GoPiGo model from the left pane, and under the Force tab in the Joints panel, apply 1 N.m torque to the left wheel. You will see how the robot starts to rotate around the right wheel, where no external force is acting:

These interactions are quite simple, and at this point, they should give you a good taste of what simulation can support your work as a robotics engineer.

Guidelines for...

Summary

In this chapter, we introduced the simulation environment of ROS called Gazebo, a standalone simulator that also provides full integration with ROS.

First, you learned about SDF, the standard XML format for robot simulation driven by Gazebo. SDF extends URDF and allows us to describe objects and environments for robot simulators, visualization, and control.

Following a parallel process to that of Chapter 4, Creating the Virtual Two-Wheeled ROS Robot, we produced a robot description within the ./urdf/gopigo.gazebo file. The simulation was then started by running ./launch/gopigo_gazebo.launch.

In this chapter, you were provided with an overview of how the Gazebo interface GUI is organized and performed some simple interactions with the GoPiGo3 model to see how it is affected by the gravity or the application of torque in the joint of one of its wheels.

By now, you should...

Questions

  1. What is the format of the SDF?

A) It is a text file
B) JSON
C) XML

  1. Why can't the UDRF format be directly used by simulation for robots?

A) Because URDF cannot specify the pose of the robot within a world
B) Because it cannot specify the dynamic properties of joints, such as stiffness, damping, and/or friction
C) All of the above

  1. What is the <collision> tag used for?

A) For defining the physical obstacles the robot has to avoid
B) It is an optional tag for performing the interference checking of robot joints
C) To define the volume to be considered for the interference checking of robot links

  1. What is the ROS find command used for?

A) It is used to refer to other ROS nodes with the same name
B) It returns the absolute path of the ROS package that is specified as its argument
C) It allows you to easily find any file within the ROS environment

  1. What is a...

Further reading

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On ROS for Robotics Programming
Published in: Feb 2020Publisher: PacktISBN-13: 9781838551308
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Bernardo Ronquillo Japón

Bernardo Ronquillo Japn is an Internet of Things (IoT) and robotics expert who has worked for top technology companies since 1995, including Instituto de Astrofsica de Canarias, Gran Telescopio Canarias, Altran, and Alestis Aerospace. Using his skills and experience, he founded The Robot Academy, where he develops open source hardware and software solutions for engineers and makers: Social Robot IO (2015), for the stimulation of children with autistic spectrum disorder; Robot JUS (2016), which helps engineers get deeper technical insights with the Robot Operating System (ROS) when using low-complexity hardware; and IIoT All-in-One (2018) as an industrial IoT training package for assisting companies in their digital transformation process.
Read more about Bernardo Ronquillo Japón