Previously I wrote a script using python to generate roslaunch files for my experiments using markup.py. The script got user’s inputs from terminal. In order to generate ros launch files efficiently, I add a function in the RosGUI for me to setup parameters easily by clicking the mouse.

I have used Boost property_tree what is Property tree to generate XML files.

By defintion, “the Property Tree library provides a data structure that stores an arbitrarily deeply nested tree of values, indexed at each level by some key. Each node of the tree stores its own value, plus an ordered list of its subnodes and their keys. The tree allows easy access to any of its nodes by means of a path, which is a concatenation of multiple keys.”

struct ptree
{
   data_type data;                         // data associated with the node
   list< pair<key_type, ptree> > children; // ordered list of named children
};

Usually, the data_type and key_type are std::string.

Here is a tutorial of using boost::property_tree

The source code to generate launch file with following format is available at github

<?xml version="1.0" encoding="utf-8"?>
<launch>
    <param type="int" name="robots_num" value="SOMEVALUE"/>
    <param type="double" name="count_down" value="SOMEVALUE"/>
    <param type="double" name="time_out" value="SOMEVALUE"/>
    <param type="double" name="sensing_range" value="SOMEVALUE"/>
    <param type="double" name="max_linear_vel" value="SOMEVALUE"/>
    <param type="bool" name="save_pose" value="TRUEORFALSE" />
    <param type="bool" name="set_pose" value="TRUEORFALSE" />
    <param type="str" name="latticegraph" value="$(find controller)lattice/SOMEFILE" />
    <!-- Must have one simulator node -->
    <node type="simulator" pkg="simulator" name="simu"> 
        <param type="double" name="env_x1" value="SOMEVALUE"/>
        <param type="double" name="env_y1" value="SOMEVALUE"/>
        <param type="double" name="env_x2" value="SOMEVALUE"/>
        <param type="double" name="env_y2" value="SOMEVALUE"/>
    </node>
    <!-- Have 1 to many controller nodes -->
    <node type="controller" pkg="controller" name="robot@"> <!-- @ represents a positive integer here -->
        <param type="int" name="robotid" value="@"/>
        <!-- @@ represents a double type number, # is a separation symbol -->
        <!-- for example, if I want the robotpose to be at point (3,4) with orientation 1.2 -->
        <!-- then the value (between double quotation marks) should be 3#4#1.2 -->
        <param type="string" name="robotpose" value="@@#@@#@@"/> 
    </node>
    ...
    <!-- Must have one shell node for animation -->
    <node type="shell" pkg="shell" name="viewrobot" output="screen"></node>
</launch>

Yang Song

Ph.D. Student in Robotics