Robotics StackExchange | Archived questions

Parameter events on foxy?

I just switched to ROS2 foxy and now my parameter events don't work anymore.
I couldn't find any documentation on what could have changed.

Basically I have a parameter blackboard node or param server and some nodes which have a param client with added remote node name of the param server, so they can listen to the param servers changes.

So on the "clients" I call this:

parameterEventSub_ = on_parameter_event(
      [this](const rcl_interfaces::msg::ParameterEvent::SharedPtr event) -> void
      {
        RCLCPP_INFO(logger, "parameterEventSub_: new params: %d", event->new_parameters.size() );

        onParameterEvent(event);  
      });

But since foxy, this doesn't work anymore.
I can see that the parameters are set exactly the same as before (eloquent), only the events are missing.

On the parameter server itself I got callbacks by using add_on_set_parameters_callback but that is a method of the node and not of the parameter client.

Does someone know how this should be done now?

Update 3.10.2020

The param event handling is working without namespaces.
But my nodes run in a namespace and then I get no events.

Asked by madmax on 2020-07-28 09:09:41 UTC

Comments

Parameter events on the client are working for me. To test with a remote node, I modified this line in the demo so that it sets parameters and listens for events on the parameter blackboard:

auto parameters_client = std::make_shared<rclcpp::SyncParametersClient>(node, "/parameter_blackboard");

If you're able to share a more complete version of code that reproduces your issue, then it might be easier to help identify the issue.

Asked by jacobperron on 2020-07-29 12:03:11 UTC

Well, I just found out, that when adding a namespace it won't work. I suppose you don't have namespaced nodes..

Asked by madmax on 2020-08-03 06:36:07 UTC

Hmm, I've tried giving different namespaces to both the parameter client and parameter server nodes and it still works as I would expect. Note, you have to update the constructor call for the parameter client to include the namespace of the server node. See my answer below.

Again, if you are able to provide a SSCCE, then it would be easier to identify the issue.

Asked by jacobperron on 2020-08-03 13:57:29 UTC

Ah, on second glance I think I was able to reproduce the issue. Can you take a look at the referenced PR in my answer and let me know if it fixes it?

Asked by jacobperron on 2020-08-03 14:08:39 UTC

Answers

If the parameter server node has a namespace, then the client must include the namespace when it is created. For example, I have my parameter server node running with the full name /foo/parameter_blackboard, then the code to create the parameter client should look like this:

auto parameters_client = std::make_shared<rclcpp::SyncParametersClient>(node, "/foo/parameter_blackboard");

Edit

I think I was able to reproduce the issue. It occurs when the local node (parameter client) has a namespace, that is also different from the remote node. I've opened a PR to address this issue in rclcpp. If you are able to try that patch and confirm if it fixes the issue that would be great.

Asked by jacobperron on 2020-08-03 13:55:48 UTC

Comments