0
$\begingroup$

Rosanswers logo

Hello All,

I have a motor controller board which is tuned using a ros node. The parameters of this board need to be tuned only once and then use the tuning parameters at each launch. Currently I have two parts to this node. Part A launches the node with parameters in a config.yaml file. The contents of which i manually typed in. Part B launches the dynamic reconfiguration tool and helps me figure out the values of these parameters ( which i manually type into config.yaml) . I can then save the current configuration from dyn reconfigure using the save icon in rqt (top left) ( let say this file is dynConfig.yaml ).

I want to launch Part A of the node using rosparam load with dynConfig.yaml as the file instead of config.yaml. If i directly use the dynConfig.yaml file in launch file i get the following error

error loading <rosparam> tag: 
    'param' attribute must be set for non-dictionary values
XML is <rosparam command="load" file="$(find drive_control)/cfg/dynConfig.yaml"/>
The traceback for the exception was written to the log file

My understanding is that this is because dynamic reconfigure adds some additional lines in the dynConfig.yaml which the rosparam is not expecting. these are the first few lines of the file when saved from rqt.

!!python/object/new:dynamic_reconfigure.encoding.Config
dictitems:
  UPLOAD_VALUES_PORT_1: false
  UPLOAD_VALUES_PORT_2: false
  groups: !!python/object/new:dynamic_reconfigure.encoding.Config
    dictitems:
      groups: !!python/object/new:dynamic_reconfigure.encoding.Config
        dictitems:
          PORT_1: !!python/object/new:dynamic_reconfigure.encoding.Config
            dictitems:

I want to know if there is a way that i can either convert dynConfig.yaml formatting to the .yaml that roslaunch expects or a way to directly save it in the right formatting. OR if i am doing it entirely the wrong way.

Thank you


Originally posted by surajmshanbhag on ROS Answers with karma: 61 on 2017-11-20

Post score: 3

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

I have faced the same problem. The root cause is that rqt_reconfigure dumps not just the dict containing the parameters, but a Config object where the parameters live.

This happens in the rqt_configure source, file dyn_reconf_client_widget.py:

def save_param(self, filename):
    configuration = self.reconf.get_configuration()
    if configuration is not None:
        with file(filename, 'w') as f:
            yaml.dump(configuration, f)

I don't think there is an easy solution for you, except if you are willing to modify the rqt_configure source code you can find the file dyn_reconf_client_widget.py and modify the second line to:

    configuration = dict(self.reconf.get_configuration())

Originally posted by knxa with karma: 811 on 2018-06-20

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by gvdhoorn on 2018-06-20:
I know it's not an answer to the question by the OP, but I believe this is what dynparam dump and dynparam load were created for.

Comment by Hakaishin on 2019-08-06:
Is there a way for dynparam dump to dump all the nodes?

$\endgroup$
0
$\begingroup$

Rosanswers logo

I completely agree, dynamic_reconfigure tutorials explanation is quite misleading, especially nodes implementation. Answering your question, you need to accomplish 5 steps:

  1. Run dynamic reconfiguration tool and tweak your parameters until it's well calibrated;

  2. Parameters are automatically stored into Parameter Server, you can find them, using:

    rosparam list | grep node

and

rosparam get /node
  1. To store your parameters for further calibration, use dynamic_reconfigure tool:

    rosrun dynamic_reconfigure dynparam dump /node config_raw.yaml

  2. To store your parameters .yaml file in type of dictionary, use standard rosparam tools:

    rosparam dump /node config.yaml

  3. Since your parameters are stored in the "right" format, you can use your parameters, e.g. by .xacro format feature

    <xacro:property name="props" value="${load_yaml('props.yaml')}"/>

as explained here , or using .launch format

<node name="dynamic_reconfigure_load" pkg="dynamic_reconfigure" type="dynparam" args="load /camera_node_name $(find my_package)/params/camera.yaml" />

for details see here.


Originally posted by artemiialessandrini with karma: 69 on 2019-11-30

This answer was NOT ACCEPTED on the original site

Post score: 4


Original comments

Comment by aguadopd on 2021-07-17:
Thanks! Note: at least for ROS 1 Noetic, rosparam dump should be used as rosparam dump config.yaml /node . See rosparam dump --help

Comment by Divelix on 2021-12-28:
Your last code snippet with load from launch file doesn't work for me. I suggest it is related to this issue, which is not yet resolved since 2015... https://github.com/ros/dynamic_reconfigure/issues/51

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.