ABOUT ME · 2018-03-25 · Gazebo is currently best used on Ubuntu. I strongly suggest a computer...
Transcript of ABOUT ME · 2018-03-25 · Gazebo is currently best used on Ubuntu. I strongly suggest a computer...
ABOUT ME
Mentasti Simone, PhD student in CS and MechanicsContacts:
Research field: Human vehicle interaction in autonomous connected cars
Slide and example link:https://goo.gl/GonArW
Logistics:
The classroom has no power source…Is it a problem?
GAZEBOSIM AND SDFROBOTICS
WHAT IS A SIMULATION
Simulation is the imitation of the operation of a real-world process or system over time. The act of simulating something first requires to develop a model; this model represents the key characteristics or behaviors/functions of the selected physical or abstract system or process. The model represents the system itself, whereas the simulation represents the operation of the system over time.
FOR WHAT PURPOSE?
Robots…are small and safe
can be easily tested in the filed
require real world interactions
But robots…can be big and dangerous
need to be tested in some specific conditions
have a behavior based on software which is prone to bugs
Moreover…as engineers we know that everything should be based on a well detailed project and should be tested and verified before any real application
FOR WHAT PURPOSE?
Robots…are small and safe
can be easily tested in the filed
require real world interactions
But robots…can be big and dangerous
need to be tested in some specific conditions
have a behavior based on software which is prone to bugs
Moreover…as engineers we know that everything should be based on a well detailed project and should be tested and verified before any real application
FOR WHAT PURPOSE?
Robots…are small and safe
can be easily tested in the filed
require real world interactions
But robots…can be big and dangerous
need to be tested in some specific conditions
have a behavior based on software which is prone to bugs
Moreover…as engineers we know that everything should be based on a well detailed project and should be tested and verified before any real application Remember to test and simulate, it can save your life!
ROBOT SIMULATORS
GOOD SIMULATOR
Realistic rendering
Physics simulation
Sensors simulation
Simplicity in building
robot models
Flexibility
Integration with robot
frameworks
ROBOT SIMULATORS
2D (player project)vs 3D (Gazebo)
Different programming languages (C++, Python, LUA, Ruby)
Different modeller (internal like Gazebo/esternal like Morse using Blender)
Different rendering engine (OpenGL, Blender, Java, Ogre)
Different sets of sensors (IMU, GPS, Collision, Laser, Cameras, ...)
ROBOT SIMULATORS
ROBOT SIMULATORS
BACK IN THE DAY…
ROS become famous
Gazebo become famous
Gazebo become part
of ROS
Gazebo regain its
independence
Currently at version 8.0
Standard de facto in robot software development
Only available 3D simulator for ROS
Development frozen at v2.0
No more part of ROS, but still compatible
WHY GAZEBO?
Main features of GazeboDynamic simulation based on various physics engines (ODE, Bullet, Simbody and DART)Sensors (with noise) simulationPlugin to customize robots, sensors and the environmentRealistic rendering of the environment and the robotsLibrary of robot models ROS integration
Advanced featuresRemote & cloud simulationOpen source
WHY GAZEBO?
Companies provides models of their robots
CUSTOMIZATION
• Modifying existing robot or sensor models• Building our own robot or sensor models• Modifying the behavior of existing robot models• Controlling and defining a behavior for our own robot
models• Creating specific environment compatible with our
experiments
What kind of customization are we looking for in a simulator?
SYSTEM REQUIREMENTS
Gazebo is currently best used on Ubuntu.I strongly suggest a computer with:
A dedicated GPUAny modern CPUAt least 500MB of free disk spaceUbuntu Xenial
Versions used in this course:Ubuntu 16.04 LTS (Xenial Xerus) & Gazebo 7.0
INSTALLATION
In a working installation of Ubuntu 16.04:$ sudo apt-get update$ sudo apt-get install gazebo7
To run Gazebo:$ gazebo
PREDICTABLE QUESTIONS
What kind of existing knowledge do I need to use Gazebo? LITTLE Can I use a different/newer/older version of Gazebo? YES (5.0/6.0/8.0)Can I use a different/newer/older version of Ubuntu? YESCan I use a different Linux distribution? YESCan I use Windows/OS X? NOCan I use a virtual machine? YESIs the use of the simulator required for the project? YESI know Gazebo and I hate it! Can I use another simulator? NO
Architecture
Separation of physics and visualization server: physics and sensor generation ($ gzserver)client: visualization and user interface ($ gzclient)
Socket communication Protobuf provides message passing
Plugin interface Control any aspect of simulation
Simulation Description Format (SDF) XML based format for worlds and models
Architecture
Physics Rendering Interfaces User Interfaces
Rigid Body dinamics OpenGL Plugins and IPC GUI
ODEBullet
...
OGRE Google ProtobufBoost ASIO
QTCEGUI
Credits:Nate Koenig
Architecture
Credits:Nate Koenig
Enviroments
Credits:Nate Koenig
Simple
Indoor
Outdoor
Creating Enviroments
Built into Gazebo
Creating Enviroments
Use external toolsSolidWorksBlender
Creating Enviroments
Download from the web3dwarehouse.sketchup.com
CREATING AND MODIFYING A MODEL
Using the model editorNewer versions of Gazebo provide tools to create and modify models directly form the user interfaceCreate object and change their shape or position using graphical toolsNice little windows to customize physical and geometrical parametersEasily connect two object with a joint
Let’s see it in action!
Using simulation description format (SDF)SDF is an evolution of the unified robot description format (URDF)An XML file format that describes environments, objects and robots for robotic simulationHierarchical and well defined“Compact” description of a complete simulated world
Sounds complex but it’s powerful and necessary
Link
https://goo.gl/GonArW
USING THE EDITOR
Why a graphical editor:-easier-faster (sometimes)-visual feedback-create good code
Open a terminal and run gazebo:$ gazebo
Open the model editor:Edit-> Model editor
USING THE EDITOR
Drag and drop a cube from the left panel to the 3D space
Click on the “Scale Mode” button to edit the box dimensions
Change the dimensions to 2m long (x axis) and 0.5m high (z axis)
USING THE EDITOR
To change the position in a more accurate way open the “Link editor” by double clicking on the object
Change the Z Pose value to 0,4 m
USING THE EDITOR
Create a wheel by dragging a cylinderThen rotate it, using the Link editor, by 90° (1,5707 rad) on the x axis.
Now we can resize it, but not using the scale button but with the Link editor.
Under the visual tab change radius to 0.3m and length to 0.25m (this change only the object appearance)
Then make the same changes under the Collision tab (this will change the “behaviour” of the object)
USING THE EDITOR
Copy and paste the “wheel” using the buttons on the top panel
Now we have some components of our car, we have to put them together and define their behaviour
To do this we will use joints
ABOUT JOINTS
Some definition“The links are the rigid members connecting the joints”
“The joints (also called axes) are the movable components of the robot that cause relative motion between adjacent links”
ABOUT JOINTS
ABOUT JOINTS
Degree of freedom definition:“In a mechanical system is the number of independent parameters that define its configuration.”
ABOUT JOINTS
Prismatic (1 DoF)
Planar (3 DoF)
Screw (1 DoF)Revolute (1 DoF)
Cilindric (2 DoF) Sphere (3 DoF)
USING THE EDITOR
Click on the joint buttonSelect the joint type, in this case revolute
Then select parent link (in our case the vehicle structure) and the child (one wheel)
Next select the joint axes, to make the wheel correctly spin we select the Z axis (we will see a yellow circle on the axis)
USING THE EDITOR
Last we select the Align links tab to attach the wheel to the body we use:
x axis: align maxy axis: align min and reverse
To create the joint press create
USING THE EDITOR
To position the wheels above the ground we will use again the link inspector and change the Z pose value to 0.3m
For the other wheel we will use similar parameters, but with y align max instead of y align min in the align links tab
Next to create the rear wheel we will use a sphere with 0.2m radius
USING THE EDITOR
Then we will apply a joint and position it above the ground as previously shown
The rear will rotate on different direction, so the joint type will not be Revolute but Ball
Last we will change the pose, with z axis value to 0.2 m.
WRITING THE CODE
SDF-xml-Developed as part of Gazebo-Describe robots and Scene-Visual design environment-SDF file in gazebo can interact with ROS code
URDF-xml-Developed as part of ROS-High ROS integration-Describe only robots-No official tools, just rviz to visualize the “robot”-URDF file can be imported in Gazebo
Two standard, SDF from Gazebo and URDF from ROS
XMLMarkup language: “A markup language is a system for annotating a document in a way that is syntactically distinguishable from the text”
Standard w3c
First version 1998
Created for web
Nowadays used in different fields:-web-DataBases-interprocess communication
<?xml version="1.0" encoding="UTF-8"?><users>
<user><name>mario</name><surname>rossi</surname><age>26</age>
</user><user>
<name>Giovanni</name><surname>Giusti</surname>
</user></users>
XMLWhy XML?
Designed to transport data
Designed to be self descriptive
Does not use predefined tags
Is extensible
<?xml version="1.0" encoding="UTF-8"?><users>
<user><name>mario</name><surname>rossi</surname><age>26</age>
</user><user>
<name>Giovanni</name><surname>Giusti</surname>
</user></users>
XMLHow it works?
-Prolog (version and encoding)
-Tags
-Three structure
-Attribute (optional)
<?xml version="1.0" encoding="UTF-8"?><users>
<user category=”admin”><name>mario</name><surname>rossi</surname><age>26</age>
</user><user category=”simple_user”>
<name>Giovanni</name><surname>Giusti</surname>
</user></users>
XML<?xml version="1.0" encoding="UTF-8"?><users>
<user category=”admin”><name>mario</name><surname>rossi</surname><age>26</age>
</user><user category=”simple_user”>
<name>Giovanni</name><surname>Giusti</surname>
</user></users>
SIMULATION DESCRIPTION FORMAT
As any XML file is composed by tags, but differently from some XML files the structure is quite simpleTag structure:
sdfworld
model
actor
light
<?xml version='1.0'?>
<sdf version='1.6'>
<world name='default'>
...
</world>
</sdf>
<?xml version='1.0'?>
<sdf version='1.6'>
<model name='model'>
...
</model>
</sdf>
<?xml version='1.0'?>
<sdf version='1.6'>
<actor name='act'>
...
</actor>
</sdf>
<?xml version='1.0'?>
<sdf version='1.6'>
<light name='light'>
...
</light>
</sdf>
SDF/ WORLD
The world represent everything inside the simulation ready to be simulatedMost important available child tags are: scene, light, model, actor, plugin, gui, include
Physics related child tags: physics, gravity, magnetic_field, spherical_coordinates
More child tags: audio, atmosphere, wind, road, state, population
sdf (model)/(light, model, actor) VS world/(light, model, actor)
A valid SDF file may contain only a single or a list object and act as an “archive”, model can be reused in different worldA world can contain different model inside the world tagA world can include external model file
SDF/MODEL
What is a model?A container for the elements of the robot (attributes: name)Composed by links and joints, or other models. Use the include tag to include previously defined models. Recursion can create really complex structures.
What is a link?Any rigid element of the robot. Child of the model tag.It has physical and visual properties and collisions
SDF/MODEL
What is a joint?Connects two links together with kinematic and dynamics propertiesVarious type of joint are available depending on the behavior of the links (revolute, spherical, …)Always defined between a parent link and a child link
pose and frame are two key elements of each of these component. Together they define the position and orientation of each element with respect to another. The correct use of reference frame can vastly simplify the construction of any complex robot.
MORE ABOUT MODELS
Models have complex structures may include various component to improve they appearance and behavior. A specific folder structure is used to define a model:
.gazebo/models/my_model: our model folder inside the main Gazebo foldermodel.config: Meta-data about the modelmodel.sdf: SDF description of the modelmeshes: a directory for all COLLADA STL files, or obj filesmaterials/texture & material/scripts: texture images and material scriptsplugins: a directory for all the code used to define the behavior of the model
SDF DEFINITION
Looks pretty simple, is this all?! Of course notYou can find the complete description of SDF here:
http://sdformat.org/spec
GENERATED CODE
Open the file generated by Gazebo (model.sdf)<?xml version='1.0'?><sdf version='1.6'> <model name='Es1'> <link name='link_3'> <pose frame=''>-0.140499 0 0.1 0 -0 0</pose> <inertial> <mass>1.17432</mass> <inertia><pose frame=''>0 0 0 0 -0 0</pose> </inertial> <gravity>1</gravity> <self_collide>0</self_collide> <kinematic>0</kinematic> <visual name='visual'> <pose frame=''>0 0 0 0 -0 0</pose> <geometry> <box> <size>1.92399 1 0.61035</size> </box> <lighting>1</lighting> <script> <uri>file://media/materials/scripts/gazebo.material</uri>….
File NamePart NamePoseStuff we didn't chooseSize
LET’S SEE AN EXAMPLE
Create a model directory: mkdir -p ~/.gazebo/models/willy2Create the configuration file: gedit ~/.gazebo/models/willy2/model.configFill the configuration file:
LET’S SEE AN EXAMPLE
Create the sdf file: gedit ~/.gazebo/models/willy2/model.sdfFill the sdf file:
BUILDING THE ROBOT
It’s important to build the robot progressively, start with a simple base and add up the other elementsThe result we want it’s something like this:
For this we need only a simple link shaped like a boxAdd the code (next slide) inside the model tag
BUILDING THE ROBOT
ADDING A CASTERA caster is a simple wheel with no constraint, it’s not connected to the body of the robot using a joint, it’s used only to sustain the weight.Since there is no joint we can add it to the base using a second collision without defining a new link.Insert the code from the next slides inside the link tags
ADDING A CASTER
ADDING A CASTER
ADDING THE WHEELS
The two wheels are real wheels, not like the caster. They are the source of the movement of the robot and they will be controlled. The wheels are defined as links and are connected to the body of the robot using joints.
ADDING THE WHEELS
ADDING THE WHEELS
ADDING THE JOINTS
We use joints to connect the wheels to the chassis.Since the wheels are constrained in any direction of movement except for the rotation around an axis we use a revolute joint.
ADDING THE JOINTS