Ask Your Question
2

Get param from a parrallel namespace

asked 2017-06-27 10:42:19 -0600

Vincent R gravatar image

updated 2017-06-28 04:31:09 -0600

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-09-25 18:39:42 -0600

130s gravatar image

updated 2018-09-26 12:44:54 -0600

(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?).

edit flag offensive delete link more

Comments

I do not test it yet but I think that it is the kind of trick that I was looking for.

Vincent R gravatar imageVincent R ( 2018-10-16 04:21:19 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2017-06-27 10:42:19 -0600

Seen: 216 times

Last updated: Sep 26 '18