Main Content


Access ROS parameter server


A ParameterTree object communicates with the ROS parameter server. The ROS parameter server can store strings, integers, doubles, Booleans, and cell arrays. The parameters are accessible globally over the ROS network. You can use these parameters to store static data such as configuration parameters.

To directly set, get, or access ROS parameters without creating a ParameterTree object, see rosparam.

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

ROS Data TypeMATLAB Data Type
32-bit integerint32
stringcharacter vector (char)
listcell array (cell)
dictionarystructure (struct)



ptree = rosparam creates a parameter tree object, ptree. After ptree is created, the connection to the parameter server remains persistent until the object is deleted or the ROS master becomes unavailable.


ptree = ros.ParameterTree(node) returns a ParameterTree object to communicate with the ROS parameter server. The parameter tree attaches to the ROS node, node. To connect to the global node, specify node as [].


expand all

This property is read-only.

List of parameter names on the server, specified as a cell array.

Example: {'/myParam';'/robotSize';'/hostname'}

Data Types: cell

Object Functions

getGet ROS parameter value
hasCheck if ROS parameter name exists
searchSearch ROS network for parameter names
setSet value of ROS parameter or add new parameter
delDelete a ROS parameter


collapse all

Start the ROS master and create a ROS node.

master = ros.Core;
Launching ROS Core...
Done in 0.68253 seconds.
node = ros.Node('/test1');

Create the parameter tree object.

ptree = ros.ParameterTree(node);

Set multiple parameters.


View the available parameters.

parameters = ptree.AvailableParameters
parameters = 3x1 cell
    {'/CellParam'  }
    {'/CharParam'  }

Get a parameter value.

data = get(ptree,'CellParam')
data=1×2 cell array
    {1x1 cell}    {1x2 cell}

Search for a parameter name.

ans = 1x1 cell array

Delete the parameter tree and ROS node. Shut down the ROS master.


Use structures to specify a dictionary of ROS parameters under a specific namespace.

Connect to a ROS network.

Launching ROS Core...
Done in 1.0395 seconds.
Initializing ROS master on
Initializing global node /matlab_global_node_47162 with NodeURI http://bat800801glnxa64:33927/

Create a dictionary of parameter values. This dictionary contains the information relevant to an image. Display the structure to verify values.

image = imread('peppers.png');

pval.ImageWidth = size(image,1);
pval.ImageHeight = size(image,2);
pval.ImageTitle = 'peppers.png';
     ImageWidth: 384
    ImageHeight: 512
     ImageTitle: 'peppers.png'

Set the dictionary of values using the desired namespace.


Get the parameters using the namespace. Verify the values.

pval2 = rosparam('get','ImageParam')
pval2 = struct with fields:
    ImageHeight: 512
     ImageTitle: 'peppers.png'
     ImageWidth: 384

Shut down ROS network.

Shutting down global node /matlab_global_node_47162 with NodeURI http://bat800801glnxa64:33927/
Shutting down ROS master on
Introduced in R2019b