<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tom Schierenebck on Medium]]></title>
        <description><![CDATA[Stories by Tom Schierenebck on Medium]]></description>
        <link>https://medium.com/@tom.schierenebck?source=rss-848048ebe0e0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Xi4rPK-CmXqzx9vMM2MrVw@2x.jpeg</url>
            <title>Stories by Tom Schierenebck on Medium</title>
            <link>https://medium.com/@tom.schierenebck?source=rss-848048ebe0e0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 19:10:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tom.schierenebck/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The dawn of a new age for AI]]></title>
            <link>https://medium.com/@tom.schierenebck/the-dawn-of-a-new-age-for-ai-75ea1696eed8?source=rss-848048ebe0e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/75ea1696eed8</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[mnist]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[markov-network]]></category>
            <dc:creator><![CDATA[Tom Schierenebck]]></dc:creator>
            <pubDate>Thu, 24 Feb 2022 09:20:48 GMT</pubDate>
            <atom:updated>2022-02-24T09:20:48.794Z</atom:updated>
            <content:encoded><![CDATA[<p>In the recent years I have further and further dove deep into the math and theory of artificial intelligence. One model in particular first caught my interest and then my heart, the Markov Random Field aka Markov Network. During my work as an auxiliary scientist in the Institute of Artificial Intelligence at the University of Bremen I discovered a polynomial way to fit an MRF. The MRF loses the fact that it is a normalized probability distribution but remains correct for every discriminatory task.</p><h3>What is an MRF?</h3><p>An MRF is a probabilistic graphical model. It represents the joint probability distribution over a set of discrete random variables. The random variables are represented as nodes and the dependencies among the random variables are represented as edges. For each maximal clique in the graph a factor Φₖ is learned. The joint probability distribution is then given by:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/0*KsmtrZpV-v1TznDL" /><figcaption>Joint probability distribution of an MRF.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/0*H8Jp804B6F_KJ5cj" /><figcaption>Partitioning function for MRFs.</figcaption></figure><p>Z is the partition function which sums over the potential of every world. Z is therefore normalizing the outputs of an MRF such that the axioms of probability hold. Calculating Z is exponential hard.</p><h3>Why are MRFs so great?</h3><p>Joint probability distributions are the key to trustworthy AI. Modern models like Neural Networks have a hard time explaining what they do and how things are related. MRFs explicitly represent dependencies and follow all rules of probability theory. Therefore any question about any possible scenario can be asked to an MRF and the probability of that is returned.</p><p>Another benefit is that the objective function of an MRF is convex. Therefore any minimum that is found is a global minimum, i. e. the optimal solution. Neural Networks suffer from their non-convex objective functions. The convergence of training is highly dependent on their hyper parameters. This lets a data scientist always remain in doubt if the results model everything informative. MRFs do not have such weakness.</p><p>But whats the deal? Why are MRFs such an unpopular choice? Until today MRFs where known to be exponential hard in their training. This is based on the fact that Z is part of the derivative of the log-likelihood function. Therefore no MRF could be applied to scenarios with many random variables.</p><p>But what if I told you that this is not the case anymore? I have found and implemented a polynomial fit for any MRF with any structure. This fit omits the calculation of the partition function and is therefore a distorted probability distribution.</p><h3>How does this new and exact method work?</h3><p>The new fit for MRFs is fairly simple. The intuition behind a factor is to represent the relative likelihood of each clique state. For example, if Φ₁(A,B) = 10 and Φ₁(A,!B) = 5, the clique expresses that A and B is twice as likely as A and not B. Therefore a clique is optimal if it represents the joint probability distribution over its variables. To represent the exact probability distribution the histogram of the cliques variables can be used. This is the limiting factor of the new MRFs. The histogram contains at most exponential many values in the number of random variables. Therefore the cliques should not be too big.</p><h3>Experiments</h3><p>The code that is used for this demonstration can be found in the repository below.</p><p><a href="https://github.com/tomsch420/torch_mrf">GitHub - tomsch420/torch_mrf</a></p><p>I will show the power of MRFs by applying the to the MNIST dataset. In the MNIST dataset 8×8 grayscale pictures and the digit they represent are stored. To apply an MRF to that scenario first a structure has to be selected.</p><p>Two approaches for the structure are common. The first is the logistic regression approach. There the assumption is made, that every pixel is independent to every other pixel given the class of the image. This results in the structure in 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mOvFgIMusPzKwT8fGSTZOg.png" /><figcaption>Figure 1: Markov Random Field structure for a logistic regression approach</figcaption></figure><p>The second approach also states that neighboring pixel are related to each other. Therefore a grid-like structure is created as depicted in figure 2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_2_4GLGWILq7YR9-URet_g.png" /><figcaption>Figure 2: Markov Random Field with grid-like structure</figcaption></figure><p>The first approach generates the confusion matrix in figure 3 with an accuracy of 94%. The second approach results in a perfect classification. The first approach needs 64⋅16⋅10 = 10240 parameters to model the distribution. The second needs 112⋅16⋅16⋅10 = 286720 parameters. In both cases most of the values are 0. Hence more efficient clique functions are interesting in the future. To give the amount of parameters more meaning I will compare them with a similar result. The sklearn handbook used Support Vector Machines to solve sich problem. These achieved an accuracy of 97% with 899 support vectors. The support vectors are samples from the dataset which define a boundary. Therefore they are 65 dimensional. Hence a support vector machine uses 65⋅899 = 58435 parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WtZIVfnyyqxflkWKDiF05Q.png" /><figcaption>Figure 3: Confusion Matrix</figcaption></figure><h3>How will this discovery influence the future of AI?</h3><p>The ability to create a model that exactly factorizes over any set of random variables is extremely valuable. It allows us to ask an artificial agent about any aspect of the world without having to fear that his answer might be irrational. Another benefit is that we can focus on modelling the dependencies within a clique. That reduces the problem from a high dimensional as a whole to many low dimensional problems. In these low dimensional problems it is easier to find accurate representations. Furthermore we can give our intuition with the task more meaning. In other models this is not possible with the same degree of freedom.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75ea1696eed8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a Gazebo with ROS2 for you own robot]]></title>
            <link>https://medium.com/creating-a-gazebo-simulation-with-ros2-for-your/introduction-8daf6efa12f4?source=rss-848048ebe0e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8daf6efa12f4</guid>
            <category><![CDATA[ros2]]></category>
            <category><![CDATA[gazebo]]></category>
            <category><![CDATA[simulation]]></category>
            <category><![CDATA[robotics]]></category>
            <dc:creator><![CDATA[Tom Schierenebck]]></dc:creator>
            <pubDate>Fri, 17 Jul 2020 08:43:34 GMT</pubDate>
            <atom:updated>2020-10-14T14:31:27.569Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<h3>Creating a Gazebo Simulation with ROS2 for your own robot</h3><h3>Section 1: Introduction</h3><p>The need for a simulator for any robot cannot be dismissed. Robots are getting more and more complex and are therefore harder to develop. Having a simulation where you can test your robot and gather data and experience with it is nice but easier said than done.</p><p>Gazebo is a powerful and accurate simulator where you can define robots and worlds and fully control them. Sadly the documentation of Gazebo is inconsistent and one has to do a lot of reading and researching through so many different tutorials to finally get a Gazebo simulation running for a custom robot and world, even for small projects.</p><p>In this article we take you through developing a Gazebo simulation for a self-driving RC car and connecting it to ROS2. We will first explain the basics of Gazebo and explain how to install everything, next we will describe how to develop a robot in Gazebo. After that we will describe how to create a world for the robot to act in. In the next section we will show you how to connect your robot simulation to ROS2 and implement your ideas of the robot with the help of ROS2. Lastly we will give some troubleshooting advice and a short insight on how Gazebo worked in our custom autonomous RC car project.</p><p>This article is intended for people who already have experience with ROS or ROS2. All examples will refer to the development of a simulation for self driving RC cars. All Examples are built and tested on Ubuntu 18.04.</p><h3>Section 2: Gazebo</h3><p>Gazebo is a simulation environment with an built-in physics engine called Ignition. Ignition allows you to simulate the robot with realistic physics. This comes in handy when you try to detect flaws in the hardware and software design of your robot. Gazebo integrates very well with ROS. You can very easily change the simulated and real hardware with Gazebo without needing to change the brain of your robot. The power and accuracy of the Gazebo simulation comes from its Simulation Description Format (SDF). Sadly it’s not very intuitive because you’ll have to know a lot about physics and the properties of your robot to create a suitable SDF file. That’s why we will take you through the development of a custom Gazebo robot in SDF in this article.</p><h3>Section 3: Installation</h3><p>To connect Gazebo with ROS2 you will have to do some installation. Let us first start with Gazebo. You can get it via one simple call in your terminal. We recommend getting the newest version of Gazebo (which is 11 at the publication of this article). Get yourself a Gazebo with</p><pre>$ curl -sSL <a href="http://get.gazebosim.org/">http://get.gazebosim.org</a> | sh</pre><p>Next you need the libraries for communication between your ROS version and your Gazebo version. The general installation scheme is as follows:</p><pre>$ sudo apt install ros-&lt;version&gt;-gazebo&lt;version number&gt;-*</pre><p>In our case we have ROS2 Dashing Diamata and Gazebo 11. This means that we have to execute</p><pre>$ sudo apt install ros-dashing-gazebo11-*</pre><p>Lastly, you can optionally install Unified Robot Description Format (URDF) and XML Macros (XACRO) parsers. These follow the same installation scheme as above. Therefore you need to run</p><pre>$ sudo apt install ros-&lt;version&gt;-urdf</pre><p>and</p><pre>$ sudo apt install ros-&lt;version&gt;-xacro</pre><p>For this article you will need to run</p><pre>$ sudo apt install ros-dashing-urdf</pre><p>and</p><pre>$ sudo apt install ros-dashing-xacro</pre><h3>Section 4: Creating a Gazebo Robot</h3><h4><strong>Section 4.1: URDF vs SDF</strong></h4><p>There are two different ways to model a robot in Gazebo. For those who already have experience in ROS or ROS2, you will already know URDF. URDF is used to describe kinematic and dynamic properties of a robot. It is written in XML and commonly used in ROS applications. However, if you want to use Gazebo, you will quickly realize that URDF files are not designed for this. Additional simulation-specific properties must be defined, so that e.g. the position of the robot can be set in the simulation.</p><p>SDF is the other option that can be used for modelling robots. It was specifically developed for Gazebo to describe robots and simulation worlds. It does everything that URDF can do, with the difference that the simulation-specific properties are added directly. For this article we will introduce and use SDF.</p><p>Gazebo converts a URDF file into an equivalent SDF file, once the simulation-specific properties have been inserted. If you already have a completed URDF file, it is more convenient to use it instead of writing a new SDF. But if you want to build your robot model from scratch and to use it later in Gazebo, we recommend using SDF.</p><p>The goal of the next sections is to provide you a basic understanding of how to use SDF. We will first introduce the basics and then cover some important tags. Subsequently, we are going to show you a real example of how to create a robot model with SDF.</p><p>We also highly recommend the official <a href="http://sdformat.org/">SDFormat.org</a> page, if you want to learn more about how to use the different tags. <br>If you are interested in preparing URDF files for Gazebo, we refer to the <a href="http://gazebosim.org/tutorials?tut=ros_urdf">tutorial</a> made by Gazebo.</p><h4><strong>Section 4.2: SDF — The basics</strong></h4><p>We will first discuss three important components of an SDF file that are used to describe a robot model:</p><ul><li>A <em>link </em>is used to describe bodies. Physical properties, such as inertia, visual and collision can be assigned to links.</li><li>The <em>joint</em>, on the other hand, is used to connect two links. One link is defined as a parent and the other one as a child.</li><li><em>Plugins </em>allow you to extend the functionalities in Gazebo by adding software that either comes from third parties or is written by yourself. However, plugins are optional, so they are not necessarily needed for robot modeling.</li></ul><p>Let us continue with the properties of a link. The <em>visual properties</em> (<em>&lt;visual&gt;</em>) are responsible for the visual presentation of the link. These can be simple geometric figures, such as spheres or cubes, or meshes that can be imported. These meshes can be provided by other developers or designed by yourself. We recommend using software such as Blender to create the meshes, which can then be exported as Collada (.dae) or Wavefront OBJ (.obj) files.</p><p>The <em>collision properties</em> (<em>&lt;collision&gt;</em>) are implemented to enable collision detection at the link. As with the visual properties, either simple geometric figures or meshes can be used. In this case we would recommend keeping the figure of the collision object as simple as possible, to reduce computing time.</p><p>The <em>&lt;inertial&gt;</em> tag is used to define properties related to mass, so that the model is treated correctly by the Gazebo physics engine. The weight of the model in kilograms is determined with <em>&lt;mass&gt;</em>. With the <em>&lt;pose&gt; </em>tag you can specify where the center of mass of the object is located . Finally, the moment of inertia of the object can be defined with <em>&lt;inertia&gt;</em>. If there is already a real model of the object, these properties can be determined on the basis of the robot parts, for example by weighing them. Alternatively you can make up the values or leave them at the default values, if this is not as important for you. However, an unfavorable weight distribution can cause the robot to behave undesirable.</p><h4>Section 4.3: SDF — Example</h4><p>Now that we know the basic components of an SDF file, we will look at a practical example in this section. We will go through the code for the <em>mule_car</em> model step by step and go into detail about the individual properties for it. The Mulecar is an autonomous RC car which was developed at the University of Bremen.</p><p>The following tags enclose the entire SDF document and define which versions of XML and SDF are used and the name of the robot model. Make sure that your Gazebo version is compatible with the SDF version, otherwise problems may appear. You can check the <a href="https://github.com/osrf/gazebo/blob/gazebo11/Changelog.md">changelogs</a> to see which SDF versions are supported.</p><p>The <em>&lt;static&gt; </em>tag ensures that the robot model is not affected by the physics engine, if it is set to <em>true</em>. This is useful if you have not placed the components of the car in the right place yet, as the car will stand still. The default assignment of <em>&lt;static&gt;</em> is <em>false</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbe34e51373ffc6fa11ce0d61e6c52c8/href">https://medium.com/media/fbe34e51373ffc6fa11ce0d61e6c52c8/href</a></iframe><p>Let us continue with <em>links</em>. We can define the position of these links in the world with <em>&lt;pose&gt;</em>. The parameter order is:</p><pre>&lt;pose&gt;x y z roll pitch yaw&lt;/pose&gt;</pre><p>The x, y and z coordinates are used to define the position of the link and the roll, pitch, yaw parameters can be used to determine the orientation of the link.</p><p>The <em>collision</em> properties of the link are defined with the <em>&lt;collision&gt;</em> tag. This tag contains the name of the collision, which must be unique, if you are using multiple collision properties inside a link.</p><p>In addition, it is mandatory to define a <em>&lt;geometry&gt; </em>tag to describe the shape of the object. Within the tag simple geometric figures, such as <em>box</em>, <em>sphere</em>, <em>cylinder</em> and <em>plane</em>, or more complex figures, like <em>mesh</em>, <em>heightmap</em>, and <em>image</em>, can be defined. As we mentioned before, stick to simple geometric figures to reduce the calculation time of collision detection. We have created a box with the dimensions 0.275 m x 0.1 m x 0.05 m for our collision object.</p><p>It is also possible to define additional &lt;pose&gt; tags in the collision properties as well as in visual properties. These are set depending on the position of the link. In our case we set the collision object in the shape of a box slightly higher than the car by increasing the z coordinate. The reason for this is that otherwise the floor and the box would have touched each other constantly, causing a collision.</p><p>The structure of the visual properties is similar to the collision properties. Inside the <em>&lt;visual&gt;</em> tag we decided to import our own mesh instead of using simple figures. For this we are using the <em>&lt;uri&gt;</em> tag to specify the path where our car model mesh can be found, which we have created with Blender beforehand.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d2556034f38cc105164009cde96998a3/href">https://medium.com/media/d2556034f38cc105164009cde96998a3/href</a></iframe><p><em>Joints</em> are used to connect different links together and to define kinematic and dynamic properties. There are many different types of joints you can use for this. <a href="http://sdformat.org/tutorials?tut=spec_model_kinematics&amp;cat=specification&amp;">In this tutorial</a> made by SDFormat.org the types are discussed in more detail.</p><p>In our case we use the type <em>revolute</em> for the wheels. It allows us to rotate the wheels along a single axis, which is specified in the <em>&lt;axis&gt; </em>tag inside the <em>&lt;xyz&gt;</em> tag. For our wheels we have set up a rotation along the z axis.</p><p>When you define joints, you must also specify which of the links is the parent and which one is the child with the <em>&lt;parent&gt; </em>and &lt;<em>child&gt; </em>tags respectively. This affects the movement of the joint as the child moves relative to the parent. Here we determine that the link <em>front_left_wheel</em> is the child of the <em>chassis</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a22ea67a53f9ce3c9d64d7035cf6c7c/href">https://medium.com/media/0a22ea67a53f9ce3c9d64d7035cf6c7c/href</a></iframe><p>We can also attach various sensors to the robot to obtain information from the environment. Gazebo already provides a variety of different sensors for this purpose, which can be added with the <em>&lt;sensor&gt;</em> tag. The type of sensor is then defined in the <em>&lt;sensor</em>&gt; tag with the <em>type</em> attribute. So if we want to add a camera for example, it would look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4dcd4ab06c03f6abb40b2d862aa98e24/href">https://medium.com/media/4dcd4ab06c03f6abb40b2d862aa98e24/href</a></iframe><p>In addition, five elements in the <em>&lt;sensor&gt; </em>tag can be configured to describe the state of the sensor. With the <em>&lt;update_rate&gt;</em> we define the frequency, how often data is generated within a cycle and depending on this we determine with <em>&lt;always_on&gt;</em> that the sensor will be continuously updated with the same frequency. We enable a graphical visualization of the sensor inputs with <em>&lt;visualize&gt;</em> and we can specify the ROS topic with <em>&lt;topic&gt;</em> on which the sensor information should be published.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe380fe988f24ec129100b4207f5e77a/href">https://medium.com/media/fe380fe988f24ec129100b4207f5e77a/href</a></iframe><p>In the following we will take a closer look at a specific sensor for an example. Using a laser sensor, we can detect objects in the environment and perform collision detection. To add such a sensor you must enter <em>ray</em> in the <em>type</em> attribute within the <em>&lt;sensor&gt;</em> tag.</p><p>In the <em>&lt;ray&gt;</em> tag you have to specify how the data should be collected and how far the range should be. With <em>&lt;scan&gt;</em> you can decide whether you want to perform horizontal (<em>&lt;horizontal&gt;</em>) or vertical (<em>&lt;vertical&gt;</em>) measurements. Then you have to define how often the environment is scanned per cycle with <em>&lt;sample&gt;</em>. Furthermore, the resolution must be specified with &lt;resolution&gt; and the angle range must be selected, which ranges from <em>&lt;min_angle&gt;</em> to <em>&lt;max_angle&gt;</em>.</p><p>The range of the laser is set within the <em>&lt;range&gt;</em> tag, where the range extends from <em>&lt;min&gt;</em> to <em>&lt;max&gt;</em> in meters. In addition, the resolution for this must also be specified here.</p><p>We have also added a plugin to create an interface of the output from the laser sensor in ROS. We have specified the topic on which we want to publish in<em> &lt;argument&gt;</em> and the type of the message in <em>&lt;output_type&gt;</em>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c0d252818d101f8a0ca1d5cf866dd0c/href">https://medium.com/media/6c0d252818d101f8a0ca1d5cf866dd0c/href</a></iframe><p>To learn more about the different sensors that Gazebo provides, we recommend the <a href="http://gazebosim.org/tutorials?cat=sensors">Gazebo tutorials</a> and the <a href="http://sdformat.org/spec?ver=1.7&amp;elem=sensor#sensor_update_rate">SDFormat.org specification</a> page.</p><p>If you have looked up the pages for the other sensors, you may have noticed that we did not use the Gazebo LIDAR sensor, but built our own LIDAR with the help of ray. We made the experience that in our case the Gazebo LIDAR did not work at all. We would like to save you some hours of work with this workaround.</p><h3>Section 5: How to create a World</h3><p>Now that we have created our robot model, we want to simulate how it behaves under different physical conditions. For this we need a world in which we can load the robot model. When we start Gazebo, a default world is already loaded. However, the default world of Gazebo is a ground plane, which not only looks completely uninteresting, but also has little to do with realistic environments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fgdELmjcW_sPFtMS" /><figcaption>Default world in Gazebo</figcaption></figure><p>Certain functionalities of a robot cannot be sufficiently simulated in this world. For instance, let’s take a look at the LIDAR in the images below, which can be used for collision detection. The default world of Gazebo contains no buildings, walls or other objects, which means that the LIDAR cannot detect anything.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NZAYeu5La53reVTU" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2j-DqU-1Vfa7Jl8y" /><figcaption>LIDAR scanning without obstacles (left) and with obstacles (right).</figcaption></figure><p>Fortunately, Gazebo offers us the possibility to import worlds and even provides us with tools to build our own worlds directly. Let’s get started with that!</p><h4>Section 5.1: Exploring the Building Editor</h4><p>Make sure that you start Gazebo with root permissions (sudo), otherwise you might not be able to save the created world, because the dialog box for this will not appear. If you are interested in a workaround for this particular problem, check out the troubleshooting in section 8.</p><p>Let’s first open the Building Editor. You can enter it under the <em>Edit</em> menu by clicking<em> Building Editor</em> or simply by pressing <em>Ctrl+B</em>. You will now see three different areas. On the left side is a palette where you can choose walls, doors, windows or stairs. It is also possible to assign colors or textures to these components. In the upper area you see a 2D view from the top-down perspective. The components from the palette can be inserted here. In addition, a floor plan can be imported, which is then displayed in this view (you will see more about this later). Finally, in the area below you can then see how the building is displayed in the simulation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kwY2F4dtRMRtBmLs" /><figcaption>Building editor of Gazebo</figcaption></figure><p>With the help of an example, we want to visualize the functionality of the Building Editor in a much more understandable way. Select the wall on the palette and move your cursor to the 2D view area. Click on a spot and move your cursor to drag the wall with the desired length. You may have noticed that you cannot set the wall completely free. The length changes only in 0,25m steps and the direction in 15° steps. But do not worry! To get full control, press <em>Shift</em> while dragging the wall. If you are not satisfied with an object you set, you can just remove it by selecting it and pressing <em>Delete</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*I21c12hLx4LfUKk3" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1o27FnolRrcIWawc" /><figcaption>Placing walls, windows and doors in Gazebo</figcaption></figure><p>After finishing your first room, you want to get inside somehow, right? Click on the door on the palette to create an opening onto any wall. And since we are on the subject of creating openings, let’s add some windows, too. Please note that you do not insert “real” doors and windows, because Gazebo does not offer it yet, so you just see holes in the wall at the moment.</p><p>You may not agree with the size of the windows, doors or walls and want to change them. For this case every component of the palette has its own inspector, where you can configure different parameters for every single object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/0*FRt16HwiHTmMD8fP" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h20_l3SVOTRNrdhk" /></figure><p>For instance, something you cannot initially influence by the time of placing a window is the size of it. Open the window inspector by double-clicking a window or by right-clicking and choosing “Open Window Inspector”. Here you can configure it to a value you desire.</p><p>You can also add stairs and therefore more floors. To do this, click on the stairs in the palette and place them somewhere in the 2D view. After you have placed the stairs, you can click on the <em>+</em> symbol above the 2D view to add another floor. Please note that you have already placed walls on the ground floor before adding another floor, as the walls will be copied to the next level. You can also select these walls afterwards and delete them with <em>Delete</em> if you want to place new walls.<br>To decide which 2D view we want to edit now, click on the drop down menu (left of the - and <em>+</em> symbols) and select the desired level. <br>If you don’t want to use the created level anymore, you can remove it with the - symbol.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yrn6Zsnukn-ynqO4" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*80i_BQXTnxLZibpC" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TOQCv7LFLHMGfcqc" /><figcaption>Building additional floors in Gazebo</figcaption></figure><p>If you got a floor map of a building, you could import it to display it on the 2D view. If you need a building based on a real example, this is a great option. This way you will be able to easily drag the walls along the template and place doors and windows in the right place. <br>To do so, click <em>Import</em> on the palette and choose the file with the floor plan you want to import.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*juslN3lqj4wUHrlZ" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6I1LJKCWApQZyUzT" /><figcaption>Import a floorplan</figcaption></figure><p>Then you have to make the right scaling so that the walls have the right length. Otherwise the measurements will not be correct. If you already know the resolution in px/m, you can enter it directly. Alternatively, you have to choose a wall whose length you know to determine the resolution. Click<em> Ok</em> and the floor plan is displayed with the correct scaling in the background of the 2D view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZJmWEImJV-woaEq1" /><figcaption>Scaling the floorplan</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wE5VBiTmvjfKE872" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F51vBbnLVoxk4Erx" /><figcaption>Tracing the walls</figcaption></figure><p>When you finish your work, it is time to save your world. First name your model on the palette. Afterwards you can save your world by pressing <em>Ctrl+S</em> or by selecting <em>File</em> in the menu and choosing <em>Save As</em>. Before exiting the Building Editor, make sure you created everything you wanted, because you will not be able to edit your model once you exit, which is a major drawback of Gazebo. No model or world is perfect at the first iteration. There will always be things to improve. Gazebo currently does not offer this option, which is very unfortunate and leads to more work.</p><p>If everything is alright and you are satisfied with your world, click <em>File</em> and select <em>Exit Building Editor</em>.</p><h4>Section 5.2: Adding more objects</h4><p>We now have a robot and a world in which it can move. But a world can also consist of much more than just walls. We also want to show you how to add different objects to the Gazebo world, which ranges from simple geometric figures to complex models from the Gazebo model database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*chd924MlqoivLdKW" /><figcaption>Geometric figures added in the world</figcaption></figure><p>We see a tab in the Gazebo window where we can already select the geometric figures and place them in the world. Click on the cylinder and move your mouse to the window to place it into the world. Afterwards you can translate, rotate or scale the objects, by selecting the icons in the tab or by pressing <em>t (translate)</em>, <em>r</em> <em>(rotate) </em>or <em>s (scale)</em> and selecting the object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lmxapk9g35RpiaaI" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d2eRgd0pNphxO9io" /><figcaption>Placing a cylinder</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8gOjnI7YuVPmnqMC" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ni043Qn596gkdQWU" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YplpHno58r_5kutd" /><figcaption>Translate, rotate and scale the cylinder</figcaption></figure><p>Besides the simple figures you can also select different models from the Gazebo model database. To get there, click on the <em>Inser</em>t tab in the selection menu on the left to open the database. Then you can choose from a variety of different models. For example you can select a table and then place it in the world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r44wvKfU_esqrY9D" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7Kju-r1lytp01RKB" /><figcaption>Placing a table</figcaption></figure><p>If you are not satisfied with some objects, you can also delete them by selecting them and pressing the <em>Delete</em> button. Alternatively you can right-click and delete the object.</p><p>When you have placed some object and want to leave, you can save your world by clicking on <em>File</em> and then <em>Save World As</em>, or by pressing <em>Ctrl+S </em>and then saving the world.</p><h3>Section 6: Implementing your robot in ROS2</h3><p>When you are implementing your robot in ROS2 you are basically forced to choose an appropriate architecture (that’s another implicit advantage of ROS2). In ROS2 every software part works independent of each other. The only relevant interfaces are the topics. Because topics have fixed types you’ll have a fixed interface description to your code. You’ll find quickly that you are also strongly encouraged to write your software independent of the existing software. This means that your software also will only communicate via topics internally and externally. Therefore the abstract architecture of your robot will probably look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/0*tdCxgkMH5pXxft0L" /><figcaption>General description of a closed loop controller</figcaption></figure><p>You will have sensors which publish their measurements over some topics to your decision making unit, i. e. the brain of your robot. The brain will then output some actions for your robot to execute. The actuators will then feedback some information, like their new pose, to your brain. This architecture is often referred to as a closed loop controller because the action feedback and action selection form an infinite closed loop.</p><p>The implementation of your sensors is in most cases not done by yourself, because most companies provide a ROS node for the sensor. Therefore you just install the node and get the sensor information. For the actuators it’s getting a bit more complicated. The common way is to send a control message to your actuators. The actuators then interpret the control instruction and behave accordingly. The way your control message is designed depends on the robot you are building. Thankfully most control messages are already implemented in ROS. You just need to choose one that is suitable for your use case. For example if you want to control a car you could write a custom message which contains the throttle and the steering the car should perform. This is bad because most ROS software works better with standard messages and therefore you will miss a lot of benefits using a custom message for this. You could also use geometry_msgs/Transform Message. This message holds a translation as 3D Vector and a Quaternion for the rotation. You can control the velocity of the car via the X-Coordinate of the 3D Vector and the steering via the Z rotation of the quaternion. This message is often used for moving tasks and therefore has a lot of support with visualisation and handling (especially with RVIZ).</p><p>If you end up with a similar architecture which separates controlling and acting/sensing in the same way it’s fine too. The benefit is now that you can just replace your sensor and actuators by simulated ones and your brain won’t care/notice. This leads us to the next point:</p><h3>Section 7: Connecting Gazebo with ROS2</h3><p>Now your previously defined SDF files and implemented robot logic will work. Usually you don’t want to start every process on your own and therefore you write launch files to start the whole robot. Unfortunately the documentation of both ROS2 and Gazebo is a bit unclear about how to invoke each other from launch files in the most comfortable way. Therefore we will show the way we did it which will work but may not be the intended one. We added</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f8917b61cd9aa790e48f594129e939c/href">https://medium.com/media/5f8917b61cd9aa790e48f594129e939c/href</a></iframe><p>to our launch file. This will launch a Gazebo server and client. After that we added</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95a89a7469c353bc3a43fc757cb5d195/href">https://medium.com/media/95a89a7469c353bc3a43fc757cb5d195/href</a></iframe><p>to our launch file. This will spawn a custom build Mulecar into the Gazebo simulation.</p><p>A slight modification can be done in the first code snippet. You can change ‘gazebo’ to ‘gzserver’ to only start the simulation without rendering it. This will boost your performance by a lot.</p><h3>Section 8: Troubleshooting</h3><p>As we mentioned before, it may be the case that your dialog box for saving the world does not display. In the following, we want to show you how you can still manage to secure the world.</p><p>For this we need to introduce some background knowledge about Gazebo. Whenever you start Gazebo, you start two processes. A parent process which is called gzserver and a child process which is called gzclient. The gzserver handles all the calculations and information storage in the world. The gzclient just renders it. So if you have run Gazebo without root permissions and your saving dialog doesn’t show you need to close the client in your terminal. This can be done by opening a new terminal and then entering the following commands:</p><pre>$ ps -a</pre><p>Then search for a process called gzclient. Remember the process id and call</p><pre>$ kill &lt;process_id&gt;</pre><p>Then your gzclient client will close and you may think you lost everything. But the gzserver is still running. You can check that again via</p><pre>$ ps -a</pre><p>and looking for a process called gzserver. Next you need to call</p><pre>$ sudo gzclient</pre><p>Then the Gazebo GUI will show up again but this time with root permissions. Wenn you try to save the world now the saving dialog will show up.</p><p>A few interesting conclusions can be drawn from the explanation above. First and most important you can speed up your simulation drastically by not starting a gzclient. Gazebo is very inefficient at rendering and therefore the gzclient process will consume most of the computing power. As a result the simulation will have to slow down in order to keep everything correct. Without the gzclient the ROS interface will still work perfectly fine. A second observation is that you can have multiple clients for one gzserver. Therefore you can render different parts of the simulations on different computers if needed.</p><h3>Section 9: Conclusion</h3><p>In this article we have shown how to create a custom Gazebo simulation for a roboter to work with ROS2. We have gone through the basics and intentions of describing robots in the SDF and how to use plugins provided by Gazebo. We have also shown how to create a world for your robot. Lastly we went through some troubleshooting for Gazebo which may occur when you are using Gazebo as a beginner. If you are interested in a project where we used Gazebo as a simulator for an autonomous RC Car you can check out the <a href="http://www.informatik.uni-bremen.de/projekttag/drive/">project website</a> and the corresponding Git repositories for the <a href="https://gitlab.informatik.uni-bremen.de/tom_sch/mulecar_simulation">Mulecar simulation</a> and <a href="https://gitlab.informatik.uni-bremen.de/staack/drive">Mulecar implementation</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4EZy6TaJ3rdfuDYpfD3LjA.png" /><figcaption>Picture of the Mulecar</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8daf6efa12f4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/creating-a-gazebo-simulation-with-ros2-for-your/introduction-8daf6efa12f4">Creating a Gazebo with ROS2 for you own robot</a> was originally published in <a href="https://medium.com/creating-a-gazebo-simulation-with-ros2-for-your">Creating a Gazebo Simulation with ROS2 for your own robot</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>