ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

We didn't provide the specific API to check if a parameter exists. There are many ways to get that information.

First is to list the parameters and check if your parameter is in the list: http://docs.ros2.org/bouncy/api/rclcpp/classrclcpp_1_1_node.html#a37aa95886a706c174db77c2b160f6d7d

Or get even more information in describe_parameters: http://docs.ros2.org/bouncy/api/rclcpp/classrclcpp_1_1_node.html#adbfb47c0983e14482c39159b274f6308

The third is to ask for the parameter and check the return code: http://docs.ros2.org/bouncy/api/rclcpp/classrclcpp_1_1_node.html#a1fe80d17fb6789dec1ecf74c4d135aad

Depending on your use case each different one has tradeoffs. If you're going to be checking more than one parameter, the listing is likely valuable. If you want to do more the descriptions are valuable. And lastly if you just use the return code you can integrate the fallback behavior inside your accessing logic.