Main Content

Get Parameter

Get ROS 2 parameter value

Since R2022b

  • ROS 2 Get Parameter Block

ROS Toolbox / ROS 2


The Get Parameter block outputs the value of the specified ROS 2 parameter associated with the node of the Simulink® model. Simulink creates this node when you run the model and deletes it when the model terminates. If the model does not have a parameter, the block creates one.

At the start of the simulation, the block initializes the ROS 2 parameter with the specified initial value. For each sample hit, the block checks the ROS 2 parameter and outputs its value.



expand all

Parameter value from the ROS 2 network, returned as a scalar or array. The type and size of this output depends on the Data type parameter.

Data Types: double | int64 | Boolean | uint8[]

Length of the array parameter, returned as an integer scalar. This length is the number of elements of the array or the number of characters in the string that you cast to uint8.


When getting string parameters from the ROS 2 network, an ASCII value of 13 returns an error due to its incompatible character type.


To enable this port, set the Data type parameter to uint8[], double[] , int64[] or boolean[].


expand all

Parameter name to get from the ROS 2 network, specified as a string. Valid parameter names have these characteristics:

  • The first character is an alpha character ([a-z|A-Z]), tilde (~), or forward slash (/).

  • Subsequent characters are alphanumeric ([0-9|a-z|A-Z]), underscores(_), or forward slashes (/).

Data type of parameter, specified as a string. Array data types such as uint8[], double[], int64[] and boolean[] enable the Maximum length parameter. If the data type changes during runtime, the block throws a warning.


The uint8[] data type is an array of ASCII values corresponding to the characters in a string. When getting string parameters, you can create a MATLAB Function (Simulink) block to compare the string to a desired parameter value.

Maximum length of the array, specified as a scalar. If the array has a length greater than Maximum length, the block returns a warning.


To enable this parameter, set the Data type parameter to uint8[], double[], int64[] or boolean[].

Default parameter value output for when an error occurs and no valid value is received from the parameter. The specified value must be a valid value for the specified Data type.

Interval between outputs, specified as a numeric scalar. The default value of -1 indicates that the block inherits the output sample time from the model. Otherwise, the block outputs a new blank message at each interval of Sample time.

For more information, see Specify Sample Time (Simulink).

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2022b

See Also