Monthly Archives: February 2014

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;

schintilla1

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 World.cc.

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.

gazebo1

 

 

#! /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 = response.read()
schema_file = open(file_name, 'w')
schema_file.write(content)
schema_file.close()
file_list = open('file_list.txt')
for line in file_list:
file_name = line.strip('\n')
file_url = "http://sdformat.org/schemas/" + 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.

 

 

#!/usr/bin/python
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')
dom.writexml(file_handle)
file_handle.close()
file_list = open('file_list.txt')
for line in file_list:
file_name = line.strip('\n')
replace_includes(file_name)

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