Search code examples
pythonparametersrosargs

Passing Array of dict as parameter to ros launch


I want to pass an array of dict as parameter to launch file and retrieve these arrays at the node. How can I achieve this. Not finding any example or pseudo-code regarding this. Newbie ros user. Regards


Solution

  • For this, you should use rosparams. This will let you pass in data in a YAML format. If loading the params in a python node they will come in as a dict, if c++ they will come in as a std::map.

    For example, if you wanted it to behave like:

    my_dict = {key1: {iKey1: val1, iKey2: val2}, key2: [1,2,3], key3: something_else}

    your launch file would look like this:

    <rosparam>
        my_dict:
            key1:
                iKey1: val1
                iKey2: val2
            key2: [1,2,3]
            key3: something_else
    </rosparam>