Skip to content

Commit b6633be

Browse files
committed
Update README.md
1 parent fc2a9af commit b6633be

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

README.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Additionally, dynamic parameters and custom validation are made easy.
77
* Declarative YAML syntax for ROS 2 Parameters converted into C++ or Python struct
88
* Declaring, Getting, Validating, and Updating handled by generated code
99
* Dynamic ROS 2 Parameters made easy
10-
* Custom user specified validator functions
10+
* Custom user-specified validator functions
1111
* Automatically create documentation of parameters
1212

1313
## Basic Usage
@@ -81,7 +81,7 @@ generate_parameter_module(
8181
)
8282
```
8383

84-
### Use generated struct into project source code
84+
### Use generated struct in project source code
8585

8686
**src/turtlesim.cpp**
8787
```c++
@@ -181,7 +181,7 @@ cpp_namespace:
181181
type: int,
182182
default_value: 3,
183183
read_only: true,
184-
description: "A read only integer parameter with a default value of 3",
184+
description: "A read-only integer parameter with a default value of 3",
185185
validation:
186186
# validation functions ...
187187
}
@@ -212,11 +212,11 @@ The types of parameters in ros2 map to C++ types.
212212
| string_fixed_XX | `FixedSizeString<XX>` |
213213
| none | NO CODE GENERATED |
214214

215-
Fixed size 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.
216216
The corresponding C++ type is a data wrapper class for conveniently accessing the data.
217217
Note that any fixed size type will automatically use a `size_lt` validator. Validators are explained in the next section.
218218

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.
220220

221221
### Built-In Validators
222222
Validators are C++ functions that take arguments represented by a key-value pair in yaml.
@@ -316,7 +316,7 @@ validation: {
316316
```
317317

318318
### Nested structures
319-
After the top level 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
320320
the same name as the key.
321321

322322
```yaml
@@ -328,7 +328,7 @@ cpp_name_space:
328328
}
329329
```
330330

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`
332332

333333
### Mapped parameters
334334
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:
340340
default_value: ["joint1", "joint2", "joint3"],
341341
description: "specifies which joints will be used by the controller",
342342
}
343+
interfaces: {
344+
type: string_array,
345+
default_value: ["position", "velocity", "acceleration"],
346+
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
343356
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
347360
}
348361
```
349362

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`.
351364

352365
### Use generated struct in Cpp
353366
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_)) {
373386
374387
### Parameter documentation
375388
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.
377390
378391
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.
379392
@@ -421,7 +434,7 @@ force_torque_broadcaster_controller:
421434
See [cpp example](example/) or [python example](example_python/) for complete examples of how to use the generate_parameter_library.
422435
423436
### Generated code output
424-
The generated code is primarily consists of two major components:
437+
The generated code primarily consists of two major components:
425438
1) `struct Params` that contains values of all parameters and
426439
2) `class ParamListener` that handles parameter declaration, updating, and validation.
427440
The general structure is shown below.
@@ -458,7 +471,7 @@ class ParamListener {
458471
// loop over all parameters: perform validation then update
459472
rcl_interfaces::msg::SetParametersResult update(const std::vector<rclcpp::Parameter> &parameters);
460473
461-
// declare all parameters and throw exception if non-optional value is missing or validation fails
474+
// declare all parameters and throw an exception if a non-optional value is missing or validation fails
462475
void declare_params(const std::shared_ptr<rclcpp::node_interfaces::NodeParametersInterface>& parameters_interface);
463476
464477
private:

0 commit comments

Comments
 (0)