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