User login

uwsim: Scene building through xacro.

As some people were commenting, maintaining XML scenes was quite complicated due to the need of copying and pasting large blocks of XML, mostly unedited, from file to file. This caused huge problems on consistency, for instance the "same" simulated sensor could be different on each scene. In order to solve this we added a xacro processing on the build compilation and few suggested macros have been created to help with this issue. If you don't know what xacro is you can check this.  This feature is called at build time, so only source-based installation will have it automatically, although deb users can build their xacro files manually using "xacro.py". What we suggest is to use four main files for macro libraries, to know:

  • Common: Basic generic macros for UWSimScenes.
  • DeviceLibrary: intended for sensors and interfaces, some added as example.
  • ObjectLibrary: Common used objects such as cirs terrain or blackbox should be available here, so there is no need to remember 3d mesh file, offsets or physics configuration to add them on a scene.
  • VehicleLibrary: library for vehicles (uses deviceLibrary to add sensors). This way we can easily maintain different configurations for vehicles and add the whole vehicle in a scene instead of copying it.

And then in the scene xacro file (.xml.xacro) call this macros to build the scene. This allows to have a unique library for sensors, objects and vehicles and just call the macro in each scene where it is used. An example has also been added, "xacroExample.xml.xacro", which creates the 424 lines "cirs.xml" scene, with just 35 lines!.  
 
Finally some lines have been added to CMakeLists so ".xml.xacro" files present on data/scenes are automatically built on catkin_make. Also, if any of this files suffers any changes is rebuilt on the next catkin_make, so there is no need to call "rosrun xacro....". The only drawback is changes on the libraries will require a manual rebuild.

We have added examples and more detailed information on how to do it in our wiki.
 
I hope this example helps you to create your own macro library and finish with the inconsistency problems!