0
$\begingroup$

Rosanswers logo

I try to figure out the best way to get param from a parallel namespace in my node code.

Here is my use case :

  • I have a parameter b in namespace /a/
  • A node launch in namespace /c/d/ where I try to access param b
  • The namespace names and organisation can change and I do not know how

I try to use ros::param:search but it is only useful when you know the parameter namespace path


Originally posted by Vincent R on ROS Answers with karma: 365 on 2017-06-27

Post score: 3

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

(Assumption: you know the parameter names and they won't change.)

I don't know if there's official API to achieve what you want. I've also browsed through issues and pull requests on ros_comm but couldn't find anything relevant.

You can find the parameter full names that contains the parameter name (say "baa") in Python by something like:

lislis = [n for n in rospy.get_param_names() if n.rsplit('/', 1)[-1] == "baa"]

print(lislis)
['/namespace_foo/foobin/baa']

Note that this snippet is obviously not robust, as it is not searching the param name specifically.


UPDATE) I too wanted a way to search parameter names downward (i.e. "from left to right"). But AFAIK there's only upward search (e.g. search_param). My guess is that there can be multiple leaves of the parameter name (the right-most portion. E.g. "baa" in the example above) can exist (while the root of namespace must be unique) so that searching a leaf name can return multiple elements and thus won't be as useful (because it's hard to write a deterministic logic with multiple parameters returned?).


Originally posted by 130s with karma: 10937 on 2018-09-25

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Vincent R on 2018-10-16:
I do not test it yet but I think that it is the kind of trick that I was looking for.

$\endgroup$

Your Answer

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