ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The .xml launch files do not support reading from the ROS parameter server.

You can go around this limitation by creating a simple python script which reads from the parameter server, concatenates the value, and then stores the concatenated value back to the parameter server. Then you can call this script from your .launch files passing the .xml arguments to the python function.

my_launch.launch file example: <launch>
<arg name="value"/>

<node                                                                                            
    pkg="my_pkg"                                                                    
    name="add_to_param_server"                                            
    type="add_to_param_server.py"                                                                      
    args="$(value)"                                                         
    output="screen"                                                                              
/>

</launch>

add_to_param_server.py example:

import rospy, sys
if __name__ == '__main__':
try:
    value = rospy.myargv(argv=sys.argv)[-1]
    var = '/thing_to_append'

    if not rospy.has_param(var):
        rospy.set_param(var, [value])
    else:
        rospy.set_param(var, rospy.get_param(var) + [value])

except rospy.ROSInterruptException:
    pass

Then you can just roslaunch my_launch.launch value=:<something>. You can add another arg to select the variable in the ROS parameter server you want to append to.