Robotics StackExchange | Archived questions

Check whether parameter is set or not for a ros 2 node

In ROS 2 RCLCPP, is there any way to be sure whether a parameter is set or not for a paricular node ? In ROS 1 , the getParam() function used to do this check.

I found the method SyncParametersClient::has_parameter(const std::string & parameter_name) inside the parameter_client.hpp code inside rclcpp. Can this ported for AsyncParameters too ?

Asked by Skyking on 2018-04-30 03:36:47 UTC

Comments

Answers

As you already pointed out there is has_parameter on the Synchronous Client. It could be added to the Async Client as well, but we just haven't done that yet. Also it could be added to the local node parameter API (you don't need a parameter client to get and set parameters on the local node), but in all cases the implementation is basically "list parameters and ensure the one you're asking about is there", see:

https://github.com/ros2/rclcpp/blob/66a7c625319879cafb7a895385057e2d85d78c45/rclcpp/src/rclcpp/parameter_client.cpp#L364-L371

Asked by William on 2018-04-30 15:33:54 UTC

Comments