list
Description
Examples
Interact with Parameters of ROS 2 Node
Create a ROS 2 node with parameters.
nodeParams.my_double = 2.0; nodeParams.my_namespace.my_int = int64(1); nodeParams.my_double_array = [1.1 2.2 3.3]; nodeParams.my_string = "Keyparams"; mainNode = ros2node("mainNode",Parameters=nodeParams); pause(1)
Create a ros2param
object to interact with the parameters of the ROS 2 node, /node1
.
paramObj = ros2param("mainNode");
Use the set
function to change the value of the parameter my_string
.
set(paramObj,"my_string","Newparams");
Use the get
function to obtain the new value of my_string
.
stringVal = get(paramObj,"my_string")
stringVal = 'Newparams'
Use the has
function to check if the parameter my_char
exists in the ROS 2 node, /node1
.
flag = has(paramObj,"my_char")
flag = logical
0
Use the search
function to search for names of all the parameters that contain the string "my_d
". Obtain the values of the matching parameters.
[pNames,pVals] = search(paramObj,"my_d")
pNames = 2x1 cell
{'my_double' }
{'my_double_array'}
pVals=2×1 cell array
{[ 2]}
{[1.1000 2.2000 3.3000]}
Use the list
function to list the names of all parameters in the ROS 2 node.
pList = list(paramObj)
pList = 9x1 cell
{'my_double' }
{'my_double_array' }
{'my_namespace.my_int' }
{'my_string' }
{'qos_overrides./parameter_events.publisher.depth' }
{'qos_overrides./parameter_events.publisher.durability' }
{'qos_overrides./parameter_events.publisher.history' }
{'qos_overrides./parameter_events.publisher.reliability'}
{'use_sim_time' }
Input Arguments
paramObj
— ROS 2 parameter object
handle (default)
ROS 2 parameter object, specified as a ros2param
object
handle.
Output Arguments
paramList
— List of all parameter names in associated ROS 2 node
cell array
List of all parameter names in the associated ROS 2 node, returned as a cell array.
Version History
Introduced in R2022b
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)