Category Archives: SDF Editor for Gazebo – OPW project

Gazebo Dairies — A summary of last four month — OPW internship

My internship journey finished after the last four great months. I have developed SDF editor for Gazebo which allows to modify the current world model by directly modifying the SDF file loaded in the memory. I have learned a lot, enjoyed more.. Nate Koenig which is my mentor for this internship is always with me with his valuable help in order to direct me though the project and answer my questions. It was my first time to be in such a great international project, working with a person on chat. Many thanks to open source community, many thanks to OPW for encouraging girls to participate in such organizations. I have tried to log my work in this blog which is  . The codes can be found in  . As a future plan, I will continue on this project in order to make it ready for the next release of Gazebo. I will be very proud of it if I can achieve :)

Gazebo Dairies – Vol. 8 (Save – Discard – Exit Events)

Finally, I can come up with saving strategies. I offer some options to the user as listed above:

  • update: As stated before, the user would like to see the visual effect of his change made in the SDF. If he hits the update button, the changes in the SDF is realized in the world model in the memory so the visual effect can be seen in the rendering scene.
  • discard: If the user wants to take back all changes done on the SDF without any modification on the initial SDF, discard button is available. After hitting the discard button, a warning dialog is appeared in order to inform the user that the changes will be discarded. If the user accepts, initial SDF is loaded into the editor and the rendering scene is also updated (which means the changes in the world model in the memory is retrieved)

discard1 discard2 discard3 discard4

  • save as: the user can save the current sdf in the editor by hitting save as button. Save dialog will open and ask for the name of the file and the location. After saving the SDF,  the changes can not be reverted. Revert option is available between two save operations.


  • done:  the user can save the changes in the editor then exits.
  • close:  exits the editor immediately without asking for any save option.




Gazebo Dairies – Vol. 7 (Improvements in SDF Editor)

In order to add code folding property, I searched for more functional editor and encountered with Scintilla. Scintilla is an open source code editing component. It comes with complete code and you can enjoy with it as you like. You can install it also from package manager.

For the ones who want to embed this wonderful component into a QT project, QScintilla is also available.  QScintilla is a port to Qt the Scintilla editor. The SDF editor which is implemented by QScintilla is as follows;


It allows highlighting, code folding, line numbering which are needed for the SDF editor. As the SDF file gets larger, these properties will be vital.

Another point which is implemented in order to make our life easier is adding the “FIND” property. Scintilla provides some functions in order to find a word in the editor. It also provides find next function. I have created a find layout as follows for the find process. It is opened by clicking the find button, or simply by hitting the key combination (CTRL+F).

gazebo12 gazebo13

As seen, if the searched word exists in the code, the find layout turns into green, otherwise it is red. By using prev and next buttons, you can iterate over all matched words. Close button hides the find layout  as we have not large area to include it continuously.








Gazebo Dairies – Vol. 6 (SDF Change)

In order to realize the changes made on the SDF, we used factory messages which can contain a SDF string and an edit name (the name of the model). These factory messages are processed in

Currently, we can change some properties of a model through the SDF text. The related SDF of the selected model from the ModelListTree (on the left side of the main window) is shown on the SDF editor. Some properties of the model such as pose, box size can be changed within the editor. After hitting the update button of the SDF editor (located in the bottom right side), the changes are sent through the factory messages if they are valid. An example is shown in the below figure where we can change the table top size through the SDF editor.

gazebo1 gazebo2

Gazebo Dairies – Vol. 5 (SDF Validator-2)

Upon obtaining the XSD files generated for the SDF (Simulator Description Format) files of Gazebo, I have validated the text in the editor again the XSD files. If the text does not meet the format described by the XSD files, then the editor highlights the line which causes error by red and shows an error message in the box which is located just below of the editor.




#! /usr/bin/python
import urllib2
def download_file(file_url, file_name):
print "download " + file_name + " from " + file_url
response = urllib2.urlopen(file_url)
content =
schema_file = open(file_name, 'w')
file_list = open('file_list.txt')
for line in file_list:
file_name = line.strip('\n')
file_url = "" + file_name
download_file(file_url, file_name)

By this script, we can download all XSD files from the link. The file_list.txt includes the names of all XSD files.



from xml.dom.minidom import parse
def get_file_ref(file_url):
index = file_url.rfind('/')
file_name = file_url[index+1:]
return './' + file_name
def replace_includes(xml_file):
dom = parse(xml_file)
include_nodes = dom.getElementsByTagName('xsd:include')
for node in include_nodes:
node.attributes['schemaLocation'].nodeValue = get_file_ref(node.attributes['schemaLocation'].nodeValue) 
print node.attributes['schemaLocation'].nodeValue
file_handle = open(xml_file, 'w')
file_list = open('file_list.txt')
for line in file_list:
file_name = line.strip('\n')

By this script, we can replace includes with local files. For example, the line <xsd:include schemaLocation=””/> is replaced by the location of the types.xsd file which is downloaded before by utilizing the above script.

Gazebo Dairies – Vol. 4 (SDF Validator)

I have to validate the correctness of the SDF editor as the user enters new entries or change some parts of it. Since the SDF file is based on XML, I have to check for XML syntax first and then for the SDF syntax. For the XML validator, I found the Xerces C++ library which can be used to parse, manipulate and validate the XML files. It returns the line number where the error is occurred. I highlighted this line with red colour and print the error message in the widget just below the editor. In this way, the user can recognize his/her error while editing the SDF file.

The editor switched to the code editor of QT from plain text editor in order to show the line numbers and highlight the current line. SDFValidator_V1

Gazebo Dairies – Vol. 3 (SDF Selector)

The whole world model contains sdf description of each entity and gets longer and longer as the number of entity in the world model increases.  A user may get confused while he wants to modify the sdf of the only one entity (let’s say table length).  That’s why, I applied the following.

Every entity in the world model is shown in the left panel (world tree). The user can select the entity which he wants to modify from that left panel. Then, the related sdf file is shown on the sdf editor. To do this, I needed to parse the whole sdf file and extract the related part. I connected this event to an action which is fired when an entity in the world tree is selected. It is better to look at the below images.


Since no entity is selected yet, the SDF editor shows the whole sdf file.


“Table” is selected under the model, the sdf part related to “table” entity is shown.


“Turtlebot” is selected under the model, the sdf part related to “turtlebot” entity is shown.

Gazebo Dairies – Vol. 2 (Integration of SDF editor)

In Gazebo simulator, Simulation Description Format (SDF) defines the world model of the simulation. It describes the objects in the simulation with their physical and visual properties. SDF is an XML-based description language, so that we can change the world description by using a simple text editor. With Gazebo SDF Editor, we aim to change the description of the simulation while simulation is running. I added the SDF editor which shows the sdf file of the current world model which is loaded from the memory. It is shown in the below image.



I added SDF editor under Edit Tab. When you click on this, it is opened above the rendering window. Normally, the sdf files of each model element are stored under home/gazebo folder.  However, these sdf files can be different from the ones stored in the memory while the simulation is running. Since some properties of the model elements can be changed. Therefore, the sdf file shown in the editor is loaded from the memory. It is easy to get the world model by sending a request to the Gazebo server.

In order to integrate the sdf editor to GUI, I replicate the job done for building editor. I added simple plain text editor from QT and a small palette which contains update and close buttons. The below picture shows the building editor of Gazebo which allows you create an entity in the simulation world bu using the graphical interface. My aim is to present an editor which allows you directly change the simulator model file and show the result instantaneously in the rendering window as it is done with building editor. However, sdf editor allows to create detailed models on every entity in the world not only wall, window, door and stairs.



Accepted for OPW internship !!

I have just accepted for the OPW internship for the 7th round. You can find detailed information about the OPW internship program and the participating organizations and accepted interns for the current period. I will work with OSRF  (Open Source Robotic Foundation) for the Gazebo project. I will integrate a SDF editor to Gazebo in order to allow changes in the model while the simulation is running. I wish I can do my best and develop a feature which the users can benefit. I feel excited to be in such a great internship period with wonderful people. Thanks to everyone for their helps in advance !


Gazebo Dairies – Vol. 1 (warming up to Gazebo)

Gazebo GUI does not fit into my laptop and annoyingly I cannot adjust it with the setSize method. Although, it is not related to SDF editor project, I have to fix it in order to interfere with the panel which contains  simulation pause/continue buttons and run time information etc. :) After playing around Qt methods and classes, I could not find a nice solution. However, I have a workaround, I use setFixedSize method instead of resize and it handles the window size properly but qsplitter does not work properly which may be handled later on. Now, I am ready to add a text editor to gazebo. I see that it can easily be added to code by using building editor code as an example. I am studying how editors are embedded in the GUI by playing with building editor.