get

Get ROS parameter value

Description

example

pvalue = get(ptree) returns a dictionary of parameter values under the root namespace: /. The dictionary is stored in a structure.

pvalue = get(ptree,paramname) gets the value of the parameter with the name paramname from the parameter tree object ptree.

pvalue = get(ptree,namespace) returns a dictionary of parameter values under the specified namespace.

The following ROS data types are supported as values of parameters. For each ROS data type, the corresponding MATLAB® data type is also listed.

  • 32-bit integer — int32

  • Boolean — logical

  • double — double

  • strings — string scalar, string, or character vector, char

  • list — cell array (cell)

  • dictionary — structure (struct)

Examples

collapse all

Create the parameter tree. A ROS network must be available using rosinit.

rosinit
Initializing ROS master on http://bat1074506glnxa64:41991/.
Initializing global node /matlab_global_node_90382 with NodeURI http://bat1074506glnxa64:41781/
ptree = rosparam;

Set a parameter value. You can also use the simplified version without a parameter tree:

rosparam set 'DoubleParam' 1.0

set(ptree,'DoubleParam',1.0)

Get the parameter value.

get(ptree,'DoubleParam')
ans = 1

Alternatively, use the simplified versions without using the parameter tree.

rosparam set 'DoubleParam' 2.0
rosparam get 'DoubleParam'
2

Disconnect from ROS network.

rosshutdown
Shutting down global node /matlab_global_node_90382 with NodeURI http://bat1074506glnxa64:41781/
Shutting down ROS master on http://bat1074506glnxa64:41991/.

Input Arguments

collapse all

Parameter tree, specified as a ParameterTree object handle. Create this object using the rosparam function.

ROS parameter name, specified as a character vector. This string must match the parameter name exactly.

ROS parameter namespace, specified as a string scalar or character vector. All parameter names starting with this string are listed when calling rosparam("list",namespace).

Output Arguments

collapse all

ROS parameter value, returned as a supported MATLAB data type. When specifying the namespace input argument, pvalue is returned as a dictionary of parameter values under the specified namespace. The dictionary is represented in MATLAB as a structure.

The following ROS data types are supported as values of parameters. For each ROS data type, the corresponding MATLAB data type is also listed.

  • 32-bit integer — int32

  • Boolean — logical

  • double — double

  • string — character vector (char)

  • list — cell array (cell)

  • dictionary — structure (struct)

Limitations

Base64-encoded binary data and iso 8601 data from ROS are not supported.

See Also

|

Introduced in R2019b