8000 Fix issue with rospy.set_param('') by larslue · Pull Request #2024 · ros/ros_comm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.

Fix issue with rospy.set_param('') #2024

Merged
merged 1 commit into from
Sep 4, 2020

Conversation

larslue
Copy link
Contributor
@larslue larslue commented Aug 17, 2020

ParamServerCache was making problems when setting a param on '/' or on the namespace of the node ('').

Before the change, the paramserver.py was raising an IndexError:

2020-08-17 07:24:18 (UTC)
IN [1]: rospy.set_param('', {'a': 1})
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-1-4cd7519fe9aa> in <module>()
----> 1 rospy.set_param('', {'a': 1})

/home/luetjens/catkin_ws/src/ros_comm/clients/rospy/src/rospy/client.py in set_param(param_name, param_value)
    537
    538     _init_param_server()
--> 539     _param_server[param_name] = param_value #MasterProxy does all the magic for us
    540
    541 def search_param(param_name):

/home/luetjens/catkin_ws/src/ros_comm/clients/rospy/src/rospy/msproxy.py in __setitem__(self, key, val)
    136         self.target.setParam(rospy.names.get_caller_id(), resolved_key, val)
    137         try:
--> 138             rospy.impl.paramserver.get_param_server_cache().update(resolved_key, val)
    139         except KeyError:
    140             pass

/home/luetjens/catkin_ws/src/ros_comm/clients/rospy/src/rospy/impl/paramserver.py in update(self, key, value)
     97             namespaces = [x for x in key.split(SEP) if x]
     98             # - last namespace is the actual key we're storing in
---> 99             value_key = namespaces[-1]
    100             namespaces = namespaces[:-1]
    101             d = self.d

IndexError: list index out of range

After the change, setting params works as expected. Setting on root:

2020-08-17 07:35:22 (UTC)
IN [1]: rospy.set_param('/', {'a': 4})

2020-08-17 07:35:27 (UTC)
IN [2]: rospy.get_param('/')
OUT [2]: {'a': 4}

2020-08-17 07:35:35 (UTC)
IN [3]: rospy.set_param('/', {'a': 5})

2020-08-17 07:35:36 (UTC)
IN [4]: rospy.get_param('/')
OUT [4]: {'a': 5}

Setting on the namespace of the node:

2020-08-17 08:12:10 (UTC)
IN [1]: rospy.set_param('', {'a': 5})

2020-08-17 08:12:12 (UTC)
IN [2]: rospy.get_param('')
OUT [2]: {'a': 5}

ParamServerCache was making problems when setting a param on '/' or on
the namespace ('').
@dirk-thomas dirk-thomas added the bug label Sep 4, 2020
@dirk-thomas
Copy link
Member

Thanks for the patch.

@dirk-thomas dirk-thomas merged commit 6435db2 into ros:noetic-devel Sep 4, 2020
jacobperron pushed a commit that referenced this pull request Oct 16, 2020
ParamServerCache was making problems when setting a param on '/' or on
the namespace ('').

Co-authored-by: Lars Lütjens <luetjens@magazino.eu>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0