0
$\begingroup$

Rosanswers logo

I want to call it in code, instead of in terminal. What API should I call?

Also is it true that if I call the API, all nodes that implemented on_parameter_event will be notified? Given they will be notified by calling ros2 param set.


Originally posted by ahtsan on ROS Answers with karma: 112 on 2019-07-12

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

This is the closest equivalent:

http://docs.ros2.org/dashing/api/rclcpp/classrclcpp_1_1SyncParametersClient.html#a267b96b3d93929404ac8ac4e83214831

In that is can set one or more parameters on any node (remote or local) by name and will return when the setting of the parameter is complete (synchronous).

There is an Asynchronous version as well which returns a future:

http://docs.ros2.org/dashing/api/rclcpp/classrclcpp_1_1AsyncParametersClient.html#a192ef60deac868dd9ad1071fc6e88c4e

Here's the examples:

https://github.com/ros2/demos/blob/f78dcc981cc783aad162e2a8530a7aa23c4fda21/demo_nodes_cpp/src/parameters/set_and_get_parameters.cpp#L40-L72

Note that in this example it is getting and setting parameters on the local node, but you can also use the same class to get and set parameters on remote nodes given their name.


Originally posted by William with karma: 17335 on 2019-07-12

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by ahtsan on 2019-07-12:
The API only accepts a node object as argument. How can we pass the name of the node instead of the node object?

Comment by ahtsan on 2019-07-12:
Also if we call set_parameters(...), will all nodes that implemented on_parameter_event be notified?

$\endgroup$

Your Answer

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