Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recent versions of PyYAML break dynamic_reconfigure_load #179

Open
PPeltzer opened this issue Jun 25, 2021 · 1 comment
Open

Recent versions of PyYAML break dynamic_reconfigure_load #179

PPeltzer opened this issue Jun 25, 2021 · 1 comment

Comments

@PPeltzer
Copy link

PPeltzer commented Jun 25, 2021

There seems to be recent API changes in PyYAML (either starting at 5.3.1 or 5.4) which will cause dynamic_reconfigure_load to crash on Ubuntu 20.04 with ROS noetic.

Given this example dynamic_reconfigure setup:

#!/usr/bin/env python

# set ROS package name
PACKAGE = "my_package"

from dynamic_reconfigure.parameter_generator_catkin import *

gen = ParameterGenerator()

# define parameters
gen.add("parameter_float",  double_t,   0,  "floating point number parameter",  0.5, 0.0, 1.0)
gen.add("parameter_bool",   bool_t,     0,  "boolean parameter",                True)
gen.add("parameter_string", str_t,      0,  "string parameter",                 "Hello World!")

nodeNameForDocumentation = "my_node"
thisConfigFile = os.path.splitext(os.path.basename(__file__))[0] # the generated header will be prefixed by this file's name (<thisConfigFile>Config.h)
exit(gen.generate(PACKAGE, nodeNameForDocumentation, thisConfigFile))

and an input config.yaml file exported by rqt_reconfigure:

!!python/object/new:dynamic_reconfigure.encoding.Config
dictitems:
  groups: !!python/object/new:dynamic_reconfigure.encoding.Config
    dictitems:
      groups: !!python/object/new:dynamic_reconfigure.encoding.Config
        state: []
      id: 0
      name: Default
      parameter_bool: false
      parameter_float: 0.75
      parameter_string: Hello World!
      parameters: !!python/object/new:dynamic_reconfigure.encoding.Config
        state: []
      parent: 0
      state: true
      type: ''
    state: []
  parameter_bool: false
  parameter_float: 0.75
  parameter_string: Hello World!
state: []

Loading in this file from a .launch file:

<launch>
  <group ns="/my_package">
    <node pkg="my_package" type="my_node" name="my_node"/>
  </group>
  <node name="dynamic_reconfigure_load" pkg="dynamic_reconfigure" type="dynparam" args="load /my_package/my_node $(find my_package)/config.yaml" />
</launch>

Results in the following crash:

Traceback (most recent call last):
  File "/opt/ros/noetic/lib/dynamic_reconfigure/dynparam", line 240, in <module>
    elif cmd == 'load':                do_load()
  File "/opt/ros/noetic/lib/dynamic_reconfigure/dynparam", line 162, in do_load
    for doc in yaml.load_all(f.read()):
  File "/home/rosuser/.local/lib/python3.8/site-packages/yaml/__init__.py", line 130, in load_all
    yield loader.get_data()
  File "/home/rosuser/.local/lib/python3.8/site-packages/yaml/constructor.py", line 45, in get_data
    return self.construct_document(self.get_node())
  File "/home/rosuser/.local/lib/python3.8/site-packages/yaml/constructor.py", line 55, in construct_document
    data = self.construct_object(node)
  File "/home/rosuser/.local/lib/python3.8/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/home/rosuser/.local/lib/python3.8/site-packages/yaml/constructor.py", line 427, in construct_undefined
    raise ConstructorError(None, None,
yaml.constructor.ConstructorError: could not determine a constructor for the tag 'tag:yaml.org,2002:python/object/new:dynamic_reconfigure.encoding.Config'
  in "<unicode string>", line 1, column 1:
    !!python/object/new:dynamic_reco ... 
    ^
[my_package/dynamic_reconfigure_load-2] process has died [pid 1185, exit code 1, cmd /opt/ros/noetic/lib/dynamic_reconfigure/dynparam load /my_package/my_node /home/rosuser/my_package/config.yaml __name:=dynamic_reconfigure_load __log:=/home/rosuser/.ros/log/12a48208-d583-11eb-a63e-0242d5aa77ae/my_package-dynamic_reconfigure_load-2.log].
log file: /home/rosuser/.ros/log/12a48208-d583-11eb-a63e-0242d5aa77ae/my_package-dynamic_reconfigure_load-2*.log

pip list outputs:

PyYAML                        5.3.1

Updating to 5.4 shows the same behaviour.


Downgrading to 5.3 however using

pip install PyYAML==5.3

fixes the crash and the parameters are loaded in correctly. Interestingly, upgrading from 5.3 to 5.3.1 appears to be safe (i.e. no crash) - so I'm not entirely sure if its 5.3.1 or 5.4 which introduces the incompatibility.

@xbroquer
Copy link

you can try #178

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants