#################################### ##FILL ME IN #################################### ## links to any required tutorials ## note.0= [[ROS/Tutorials/UnderstandingTopics|Understanding Topics]] ## note.1= [[ROS/Tutorials/UnderstandingServicesParams|Understanding ServicesParams]] ## descriptive title for the tutorial ## title = Using Parameters in roscpp ## multi-line description to be displayed in search ## description = This tutorial will show you the `NodeHandle` parameter API, allowing you to manipulate parameters from the [[Parameter Server]]. ## the next tutorial description (optional) ## next = ## links to next tutorial (optional) ## next.0.link=[[roscpp_tutorials/Tutorials/AccessingPrivateNamesWithNodeHandle|Accessing Private Names with NodeHandle]] ## next.1.link= ## what level user is this tutorial for ## level= BeginnerCategory #################################### <> <> == Retrieving Parameters == There are two methods to retrieve parameters with `NodeHandle`. In the following example code, `n` is an instance of `NodeHandle`. === getParam() === `getParam()` has a number of overloads which all follow the same basic form: {{{#!cplusplus bool getParam (const std::string& key, parameter_type& output_value) const }}} * '''key''' is a [[Names|Graph Resource Name]] * '''output_value''' is the place to put the retrieved data, where parameter_type is one of bool, int, double, string, or a special `XmlRpcValue` type which can represent any type and also lists/maps. Use of `getParam()` is fairly simple: <> Note that `getParam()` returns a bool, which provides the ability to check if retrieving the parameter succeeded or not: <> === param() === `param()` is similar to `getParam()`, but allows you to specify a default value in the case that the parameter could not be retrieved: <> Sometimes the compiler requires a hint for the string type. <> == Setting Parameters == Setting parameters is done through the `setParam()` methods: <> `setParam()`, like `getParam()`, can take bool, int, double, string, and a special `XmlRpcValue` type == Deleting Parameters == Deleting parameters is done through the `deleteParam()` method: <> == Checking for Existence == This is not usually necessary, but there is a `hasParam()` method that allows you to check for a parameter's existence: <> == Searching for Parameters == The [[Parameter Server]] allows you to "search" for parameters, starting at your namespace and working through your parent namespaces. For example, if the parameter `/a/b` exists in the parameter server, and your `NodeHandle` is in the `/a/c` namespace, `searchParam()` for `b` will yield `/a/b`. However, if parameter `/a/c/b` is added, `searchParam()` for `b` will now yield `/a/c/b`. <> '''Next Tutorial''': [[roscpp_tutorials/Tutorials/AccessingPrivateNamesWithNodeHandle|Accessing Private Names with NodeHandle]] ## AUTOGENERATED DO NOT DELETE ## TutorialCategory ## FILL IN THE STACK TUTORIAL CATEGORY HERE