Skip to content

Commit e055229

Browse files
committed
chore: update readme and examples
Signed-off-by: Bart Jimenez Vera <bjv@capra.ooo>
1 parent 52a6f98 commit e055229

5 files changed

Lines changed: 29 additions & 7 deletions

File tree

micro_ros_common_diagnostics/src/hwmonitor.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,15 @@ int main(int argc, const char * argv[])
9292
return -1;
9393
}
9494

95+
// executor
96+
rclc_executor_t executor;
97+
executor = rclc_executor_get_zero_initialized_executor();
98+
unsigned int num_handles = 1;
99+
rclc_executor_init(&executor, &context, num_handles, &allocator);
100+
95101
// updater
96102
diagnostic_updater_t updater;
97-
rc = rclc_diagnostic_updater_init(&updater, &updater_node);
103+
rc = rclc_diagnostic_updater_init(&updater, &updater_node, &executor);
98104
if (rc != RCL_RET_OK) {
99105
printf("Error in creating diagnostic updater\n");
100106
return -1;
@@ -124,7 +130,7 @@ int main(int argc, const char * argv[])
124130
sleep(1);
125131
}
126132

127-
rclc_diagnostic_updater_fini(&updater, &updater_node);
133+
rclc_diagnostic_updater_fini(&updater, &updater_node, &executor);
128134
if (rc != RCL_RET_OK) {
129135
printf("Error while cleaning up!\n");
130136
return -1;

micro_ros_diagnostic_updater/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ As mentioned, this package does not build the examples by default, to do so, you
6363
colcon build --packages-select micro_ros_diagnostic_updater --cmake-args -DMICRO_ROS_DIAGNOSTIC_UPDATER_EXAMPLES=ON
6464
```
6565

66+
### Publish only on update and Force update ###
67+
68+
The updater won't publish statuses of task who's data is unchanged, this is to reduce the traffic and processing needed by the updater on each iteration. However, due to different reasons, one may want to force the updater to publish everything. This is done with a subscription that is added to the executor passed on the initialization of the updater. The subscriber will be listening for a message of type `std_msgs/msg/Empty`, and the topic is always `<namespace>/diagnostics_uros/force_update`. Keep in mind, the `<namespace>` can be modified as indicated above.
69+
6670
## License
6771

6872
The micro-ROS diagnostics framework packages are open-sourced under the Apache-2.0 license. See the [../LICENSE](LICENSE) file for details.

micro_ros_diagnostic_updater/example/example_processor_updater.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,15 @@ int main(int argc, const char * argv[])
108108
return -1;
109109
}
110110

111+
// executor
112+
rclc_executor_t executor;
113+
executor = rclc_executor_get_zero_initialized_executor();
114+
unsigned int num_handles = 1;
115+
rclc_executor_init(&executor, &context, num_handles, &allocator);
116+
111117
// updater
112118
diagnostic_updater_t updater;
113-
rc = rclc_diagnostic_updater_init(&updater, &my_node);
119+
rc = rclc_diagnostic_updater_init(&updater, &my_node, &executor);
114120
if (rc != RCL_RET_OK) {
115121
printf("Error in creating diagnostic updater\n");
116122
return -1;
@@ -157,7 +163,7 @@ int main(int argc, const char * argv[])
157163
sleep(1);
158164
}
159165

160-
rclc_diagnostic_updater_fini(&updater, &my_node);
166+
rclc_diagnostic_updater_fini(&updater, &my_node, &executor);
161167
if (rc != RCL_RET_OK) {
162168
printf("Error while cleaning up!\n");
163169
return -1;

micro_ros_diagnostic_updater/example/example_website_checker.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,15 @@ int main(int argc, const char * argv[])
101101
return -1;
102102
}
103103

104+
// executor
105+
rclc_executor_t executor;
106+
executor = rclc_executor_get_zero_initialized_executor();
107+
unsigned int num_handles = 1;
108+
rclc_executor_init(&executor, &context, num_handles, &allocator);
109+
104110
// updater
105111
diagnostic_updater_t updater;
106-
rc = rclc_diagnostic_updater_init(&updater, &my_node);
112+
rc = rclc_diagnostic_updater_init(&updater, &my_node, &executor);
107113
if (rc != RCL_RET_OK) {
108114
printf("Error in creating diagnostic updater\n");
109115
return -1;
@@ -135,7 +141,7 @@ int main(int argc, const char * argv[])
135141
sleep(1);
136142
}
137143

138-
rclc_diagnostic_updater_fini(&updater, &my_node);
144+
rclc_diagnostic_updater_fini(&updater, &my_node, &executor);
139145
if (rc != RCL_RET_OK) {
140146
printf("Error while cleaning up!\n");
141147
return -1;

micro_ros_diagnostic_updater/src/micro_ros_diagnostic_updater/micro_ros_diagnostic_updater.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ rclc_diagnostic_task_init(
104104

105105
void force_update_callback(const void * msgin, void * updater_ptr)
106106
{
107-
//we ignore msgin as it's empty
107+
// we ignore msgin as it's empty
108108
(void) msgin;
109109
diagnostic_updater_t * updater = (diagnostic_updater_t *) updater_ptr;
110110
updater->force_update = true;

0 commit comments

Comments
 (0)