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

Rosparam load without overriding

asked 2014-06-13 12:09:55 -0600

crpizarr gravatar image

Is there a way to load a .yaml file without overriding parameters? I have two independent .launch files that depend on the same .yaml file storing the configuration of the package, but one section of the package (corresponding to a one .launch file) might change the parameters (without dumping into the .yaml file), and the other section needs to get the newest parameters, which in this case would be those in the parameter server, not in the .yaml file.

Thanks in advance

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-06-13 12:13:21 -0600

ahendrix gravatar image

I don't believe you can do this with rosparam.

Instead, you should architect your launch files so that this isn't a problem. Perhaps you could create a third launch file just for loading parameters at startup?

edit flag offensive delete link more

answered 2014-10-06 12:22:40 -0600

romay gravatar image

updated 2014-10-06 16:29:07 -0600

I ran into the same issue and ended up creating this script:

# $0 is the script name, $1 id the first ARG, $2 is second...

if [ "$2" = "" ]
  echo "Usage: $0 <filename> <namespace>"
  dump_command="rosparam dump"
  load_command="rosparam load"

  IS_NAMESPACE=$(rosparam list | /bin/egrep "$NAMESPACE")

  if [ -z "$IS_NAMESPACE" ];
    echo "No previous Namespace found, simply loading new parameters"
    command="$load_command $FILE $NAMESPACE"
    eval $command

    #Dumps the current parameters in the server
    command="$dump_command dump_tmp.txt $NAMESPACE"
    eval $command

    #Temporarly loads the new parameters
    command="$load_command $FILE $NAMESPACE"
    eval $command

    #Dumps the new parameters
    command="$dump_command load_tmp.txt $NAMESPACE"
    eval $command

    #Appends both files
    cat dump_tmp.txt >> load_tmp.txt

    #Loads all the new parameters
    command="$load_command load_tmp.txt $NAMESPACE"
    eval $command

    #Remove temporary files
    rm load_tmp.txt
    rm dump_tmp.txt

I called this script file "rosparam_append" and it takes as arguments the new .yaml file to append and the namespace (if there's no namespace, the simple rosparam load command is executed)


rosparam_append [path/to/your].yaml /[your_namespace]

you can use this script in your launch file (from this answer):

<node name    = "rosparam_append_node" 
      pkg     = "your-package-name"
      type    = "rosparam_append"
      args    = "$(find your-package-name)/path/to/your.yaml /your/namespace"/>

remember to give executable permissions to the script with:

chmod 755 rosparam_append

hope it helps

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2014-06-13 12:09:55 -0600

Seen: 1,124 times

Last updated: Oct 06 '14