You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-14Lines changed: 27 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ Additionally, dynamic parameters and custom validation are made easy.
7
7
* Declarative YAML syntax for ROS 2 Parameters converted into C++ or Python struct
8
8
* Declaring, Getting, Validating, and Updating handled by generated code
9
9
* Dynamic ROS 2 Parameters made easy
10
-
* Custom userspecified validator functions
10
+
* Custom user-specified validator functions
11
11
* Automatically create documentation of parameters
12
12
13
13
## Basic Usage
@@ -81,7 +81,7 @@ generate_parameter_module(
81
81
)
82
82
```
83
83
84
-
### Use generated struct into project source code
84
+
### Use generated struct in project source code
85
85
86
86
**src/turtlesim.cpp**
87
87
```c++
@@ -181,7 +181,7 @@ cpp_namespace:
181
181
type: int,
182
182
default_value: 3,
183
183
read_only: true,
184
-
description: "A readonly integer parameter with a default value of 3",
184
+
description: "A read-only integer parameter with a default value of 3",
185
185
validation:
186
186
# validation functions ...
187
187
}
@@ -212,11 +212,11 @@ The types of parameters in ros2 map to C++ types.
212
212
| string_fixed_XX |`FixedSizeString<XX>`|
213
213
| none | NO CODE GENERATED |
214
214
215
-
Fixedsize types are denoted with a suffix `_fixed_XX`, where `XX` is the desired size.
215
+
Fixed-size types are denoted with a suffix `_fixed_XX`, where `XX` is the desired size.
216
216
The corresponding C++ type is a data wrapper class for conveniently accessing the data.
217
217
Note that any fixed size type will automatically use a `size_lt` validator. Validators are explained in the next section.
218
218
219
-
The purpose of `none` type is purely documentation, and won't generate any C++ code. See [Parameter documentation](#parameter-documentation) for details.
219
+
The purpose of the `none` type is purely documentation, and won't generate any C++ code. See [Parameter documentation](#parameter-documentation) for details.
220
220
221
221
### Built-In Validators
222
222
Validators are C++ functions that take arguments represented by a key-value pair in yaml.
@@ -316,7 +316,7 @@ validation: {
316
316
```
317
317
318
318
### Nested structures
319
-
After the toplevel key, every subsequent non-leaf key will generate a nested c++ struct. The struct instance will have
319
+
After the top-level key, every subsequent non-leaf key will generate a nested C++ struct. The struct instance will have
320
320
the same name as the key.
321
321
322
322
```yaml
@@ -328,7 +328,7 @@ cpp_name_space:
328
328
}
329
329
```
330
330
331
-
The generated parameter value can then be access with `params.nest1.nest2.param_name`
331
+
The generated parameter value can then be accessed with `params.nest1.nest2.param_name`
332
332
333
333
### Mapped parameters
334
334
You can use parameter maps, where a map with keys from another `string_array` parameter is created. Add the `__map_` prefix followed by the key parameter name as follows:
@@ -340,14 +340,27 @@ cpp_name_space:
340
340
default_value: ["joint1", "joint2", "joint3"],
341
341
description: "specifies which joints will be used by the controller",
description: "interfaces to be used by the controller",
347
+
}
348
+
# nested mapped example
349
+
gain:
350
+
__map_joints: # create a map with joints as keys
351
+
__map_interfaces: # create a map with interfaces as keys
352
+
value: {
353
+
type: double
354
+
}
355
+
# simple mapped example
343
356
pid:
344
-
__map_joints: # create a map with joints as keys
345
-
param_name: {
346
-
type: string_array
357
+
__map_joints: # create a map with joints as keys
358
+
values: {
359
+
type: double_array
347
360
}
348
361
```
349
362
350
-
The generated parameter value can then be access with `params.pid.joints_map.at("joint1").param_name`.
363
+
The generated parameter value for the nested map example can then be accessed with `params.gain.joints_map.at("joint1").interfaces_map.at("position").value`.
351
364
352
365
### Use generated struct in Cpp
353
366
The generated header file is named based on the target library name you passed as the first argument to the cmake function.
@@ -373,7 +386,7 @@ if (param_listener->is_old(params_)) {
373
386
374
387
### Parameter documentation
375
388
376
-
In some case, parameters might be unknown only at compile-time, and cannot be part of the generated C++ code. However, for documentation purpose of such parameters, the type `none` was introduced.
389
+
In some cases, parameters might be unknown only at compile-time, and cannot be part of the generated C++ code. However, for documentation purpose of such parameters, the type `none` was introduced.
377
390
378
391
Parameters with `none` type won't generate any C++ code, but can exist to describe the expected name or namespace, that might be declared by an external piece of code and used in an override.
0 commit comments