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
@@ -9,13 +9,20 @@ ROS 2 parameters allow the user to create variables on a node and manipulate/rea
9
9
10
10
Ready to use code related to this tutorial can be found in [`rclc/rclc_examples/src/example_parameter_server.c`](https://github.com/ros2/rclc/blob/master/rclc_examples/src/example_parameter_server.c). Fragments of code from this example is used on this tutorial.
11
11
12
-
Note: micro-ROS parameter server is only supported on ROS 2 Galactic distribution
12
+
micro-ROS parameters implementation has been upgraded in the latest micro-ROS Rolling distribution, two approaches are presented in this tutorial: micro-ROS Foxy/Galactic and micro-ROS Rolling and beyond:
@@ -33,28 +40,6 @@ Note: micro-ROS parameter server is only supported on ROS 2 Galactic distributio
33
40
}
34
41
```
35
42
36
-
- Custom options:
37
-
38
-
The user can configure whether to notify parameter changes to the rest of nodes (`notify_changed_over_dds`) and the maximum number of parameters (`max_params`) allowed on the `rclc_parameter_server_t` object:
39
-
40
-
```c
41
-
// Parameter server object
42
-
rclc_parameter_server_t param_server;
43
-
44
-
// Initialize parameter server options
45
-
constrclc_parameter_options_t options = {
46
-
.notify_changed_over_dds = true,
47
-
.max_params = 4 };
48
-
49
-
// Initialize parameter server with configured options
The parameter server uses 5 services and an optional publisher, this needs to be taken into account on the `rmw-microxredds` package memory configuration:
printf(" New value: %d (bool)", param->value.bool_value);
107
-
break;
108
-
case RCLC_PARAMETER_INT:
109
-
printf(" New value: %ld (int)", param->value.integer_value);
110
-
break;
111
-
case RCLC_PARAMETER_DOUBLE:
112
-
printf(" New value: %f (double)", param->value.double_value);
113
-
break;
114
-
default:
115
-
break;
116
-
}
117
-
118
-
printf("\n");
119
-
}
120
-
```
121
-
Once the parameter server and the executor are initialized, the parameter server must be added to the executor in order to accept parameters commands from ROS2:
122
-
```c
123
-
// Add parameter server to executor including defined callback
printf(" New value: %d (bool)", param->value.bool_value);
187
+
break;
188
+
case RCLC_PARAMETER_INT:
189
+
printf(" New value: %ld (int)", param->value.integer_value);
190
+
break;
191
+
case RCLC_PARAMETER_DOUBLE:
192
+
printf(" New value: %f (double)", param->value.double_value);
193
+
break;
194
+
default:
195
+
break;
196
+
}
197
+
198
+
printf("\n");
199
+
}
200
+
```
201
+
Once the parameter server and the executor are initialized, the parameter server must be added to the executor in order to accept parameters commands from ROS2:
202
+
```c
203
+
// Add parameter server to executor including defined callback
- notify_changed_over_dds: Publish parameters events to the rest of nodes.
221
+
- max_params: Maximum number of parameters allowed on the `rclc_parameter_server_t` object.
222
+
- allow_undeclared_parameters: Allows creation of parameters from external parameters clients. A new parameter will be created if a `set` operation is requested on a non-existing parameter.
223
+
- low_mem_mode: Reduces the memory used by the parameter server, functionality constrains are applied.
224
+
225
+
```c
226
+
// Parameter server object
227
+
rclc_parameter_server_t param_server;
228
+
229
+
// Initialize parameter server options
230
+
constrclc_parameter_options_t options = {
231
+
.notify_changed_over_dds = true,
232
+
.max_params = 4,
233
+
.allow_undeclared_parameters = true,
234
+
.low_mem_mode = false; };
235
+
236
+
// Initialize parameter server with configured options
" Old value: %d, New value: %d (bool)", old_param->value.bool_value,
283
+
new_param->value.bool_value);
284
+
break;
285
+
case RCLC_PARAMETER_INT:
286
+
printf(
287
+
" Old value: %ld, New value: %ld (int)", old_param->value.integer_value,
288
+
new_param->value.integer_value);
289
+
break;
290
+
case RCLC_PARAMETER_DOUBLE:
291
+
printf(
292
+
" Old value: %f, New value: %f (double)", old_param->value.double_value,
293
+
new_param->value.double_value);
294
+
break;
295
+
default:
296
+
break;
297
+
}
298
+
printf("\n");
299
+
}
300
+
301
+
return true;
302
+
}
303
+
```
304
+
305
+
Parameters modifications are disabled while this callback is executed, causing this methods to return `RCLC_PARAMETER_DISABLED_ON_CALLBACK`:
306
+
- rclc_add_parameter
307
+
- rclc_delete_parameter
308
+
- rclc_parameter_set_bool
309
+
- rclc_parameter_set_int
310
+
- rclc_parameter_set_double
311
+
- rclc_set_parameter_read_only
312
+
- rclc_add_parameter_constraints_double
313
+
- rclc_add_parameter_constraints_integer
314
+
315
+
316
+
Once the parameter server and the executor are initialized, the parameter server must be added to the executor in order to accept parameters commands from ROS2:
317
+
```c
318
+
// Add parameter server to executor including defined callback
0 commit comments