ROS2: Set Remote Parameter - Results in Exception

asked 2020-02-13 17:42:03 -0500

Kevlar gravatar image

Version: ROS2 Eloquent

Platform: Linux 5.0.0-37-generic #40~18.04.1-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux

I am trying to set a parameter for Node #1 from Node #2. If I understand correctly, I need to first create a SynParametersClient on Node #2:

mHelmParameters = std::make_shared<rclcpp::SyncParametersClient>(this, "Helm");

When I attempt to set the parameter:

mHelmParameters->set_parameters({ rclcpp::Parameter(parameterName, parameterValue) });

I get the following:

terminate called after throwing an instance of 'std::runtime_error'

what():  Node has already been added to an executor.

When the set_parameters() call is made, it is in the same thread/call chain from the receipt of a subscribed message. The general intent is when Node 2 receives a particular message I want to set a parameter on Node 1.

I found this thread: However, it results in a "you don't need the Client to set your own parameters." All well and good, but that doesn't help, since I'm trying to set a remote parameter.

From what I can discern from other threads and documentation, it doesn't seem feasible to do this from within the context of a 'spin' call (which, if I also understand correctly, is making the callback for the 'message received' method). Therefore, I would need to break out of the 'spin' call periodically, see that I have a parameter to set, set it, then get back to 'spinning'. If I'm incorrect in this analysis, how do I get around the thrown exception?


edit retag flag offensive close merge delete