Skip to content

Commit b3ac890

Browse files
committed
Add window_size param
Signed-off-by: Tony Najjar <[email protected]>
1 parent 5023884 commit b3ac890

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

controller_manager/src/controller_manager.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,9 @@ std::vector<std::string> ControllerManager::get_controller_names()
23222322

23232323
void ControllerManager::read(const rclcpp::Time & time, const rclcpp::Duration & period)
23242324
{
2325-
if (periodicity_stats_.GetCount() >= 100)
2325+
if (
2326+
periodicity_stats_.GetCount() >=
2327+
params_->diagnostics.threshold.controller_manager.periodicity.window_size)
23262328
{
23272329
periodicity_stats_.Reset();
23282330
}
@@ -2503,11 +2505,23 @@ controller_interface::return_type ControllerManager::update(
25032505
controller_ret = trigger_result.result;
25042506
if (trigger_status && trigger_result.execution_time.has_value())
25052507
{
2508+
if (
2509+
loaded_controller.execution_time_statistics->GetCount() >=
2510+
params_->diagnostics.threshold.controllers.periodicity.window_size)
2511+
{
2512+
loaded_controller.execution_time_statistics->Reset();
2513+
}
25062514
loaded_controller.execution_time_statistics->AddMeasurement(
25072515
static_cast<double>(trigger_result.execution_time.value().count()) / 1.e3);
25082516
}
25092517
if (!first_update_cycle && trigger_status && trigger_result.period.has_value())
25102518
{
2519+
if (
2520+
loaded_controller.periodicity_statistics->GetCount() >=
2521+
params_->diagnostics.threshold.controllers.periodicity.window_size)
2522+
{
2523+
loaded_controller.periodicity_statistics->Reset();
2524+
}
25112525
loaded_controller.periodicity_statistics->AddMeasurement(
25122526
1.0 / trigger_result.period.value().seconds());
25132527
}

controller_manager/src/controller_manager_parameters.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ controller_manager:
2929
threshold:
3030
controller_manager:
3131
periodicity:
32+
window_size: {
33+
type: int,
34+
default_value: -1,
35+
description: "The number of samples to consider for the mean. The diagnostics will be computed over the last `window_size` samples. -1 means that all samples will be considered.",
36+
}
3237
mean_error:
3338
warn: {
3439
type: double,
@@ -65,6 +70,11 @@ controller_manager:
6570
}
6671
controllers:
6772
periodicity:
73+
window_size: {
74+
type: int,
75+
default_value: -1,
76+
description: "The number of samples to consider for the mean. The diagnostics will be computed over the last `window_size` samples. -1 means that all samples will be considered.",
77+
}
6878
mean_error:
6979
warn: {
7080
type: double,

0 commit comments

Comments
 (0)