0
$\begingroup$

As far as I know, it is not possible to set parameters in the '/' namespace from a ROS 2 node, unlike ROS 1. All the parameter set from the ROS 2 node falls in the /node_name. I just wanted to confirm whether that is correct or not.

I have some parameters that I want to set as global parameters that can be accessible by all the other nodes, even if the name of the node declaring those parameters changes. Is it possible with ROS 2?

$\endgroup$

2 Answers 2

0
$\begingroup$

ROS 2 doesn't have a global parameter server included, each node has their own parameter contexts. So no, by default, you can't set global parameters via the ROS 1 parameter server. With that said:

  • There's Parameter Client objects you can use to get parameters from other nodes easily as a service call, so that's an option
  • There are community tools for global parameter servers in ROS 2. But, they're basically just using the tool from bullet 1 above to get them, so semantically not all that different
  • Something we do in Nav2 is to add parameters to each node's namespace in our launch system. For example, we set the global use_sim_time for all nodes without that field in our param files by injecting it into each namespace when we launch the nodes. So, if you globally want something set, that's an option from within your launch system orchestrating the launch of each of the nodes.
$\endgroup$
2
  • $\begingroup$ Thank you for the confirmation Steve. I have one more question on the parameter server of the ros2 node. Suppose I have parameters declared in 1st node named node_1 that I am accessing in 2nd node named client_node. Now, if I decide to change the name of the 1st node to node_x, I will have to take that into account in the client_node as well, right? Is there any way around to automatically take into account the name change of the 1st node to access the parameters of that node? One way I can see this is to pass the name of the 1st node as a parameter to the client_node. $\endgroup$
    – aarsht7
    Feb 21 at 10:52
  • $\begingroup$ Yes, its the node name, not the node type, since you could have N of the same node types running (think sensor drivers). You could probably do it automatically with remaps or parameterize the name if you know all the names at launch file $\endgroup$ Feb 21 at 17:17
0
$\begingroup$

I have also found another approach on Robotics Back-End that can be interesting to have a look at as well. You can also checkout functions for Python from here that you can use to play with param server in ROS 2

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.