Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add window size #210

Open
wants to merge 6 commits into
base: rolling
Choose a base branch
from
Open

Conversation

Tacha-S
Copy link

@Tacha-S Tacha-S commented Feb 20, 2025

I have added a window size to calculate the moving average

Signed-off-by: Tatsuro Sakaguchi <[email protected]>
@Tacha-S Tacha-S requested a review from a team as a code owner February 20, 2025 00:11
@Tacha-S Tacha-S requested review from emersonknapp and MichaelOrlov and removed request for a team February 20, 2025 00:11
Copy link
Member

@christophebedard christophebedard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, we have to consider multiple things:

  1. By default, this should probably behave like it did before, i.e., it should consider all values. The tests are currently failing because this is not the case.
  2. Tests should be added to cover the case where a window is used (probably in test/moving_average_statistics/test_moving_average_statistics.cpp).
  3. Finally: How would an end user use this? In this case, this code is ultimately used in rclcpp (see rclcpp::topic_statistics::SubscriptionTopicStatistics). From looking at the subscription creation code in rclcpp, there is no way to provide a window_size value.

@emersonknapp do you have any thoughts on this?

@Tacha-S
Copy link
Author

Tacha-S commented Feb 21, 2025

I understood points 1 and 2.

I noticed this feature in the controller manager, so I thought the user would create an instance, but it turns out that it can be enabled or disabled through the options when subscribing in rclcpp.

Signed-off-by: Tatsuro Sakaguchi <[email protected]>
Signed-off-by: Tatsuro Sakaguchi <[email protected]>
Signed-off-by: Tatsuro Sakaguchi <[email protected]>
@Tacha-S Tacha-S force-pushed the feature/window-size branch from ed4d967 to 87c9821 Compare February 21, 2025 09:29
@@ -52,6 +53,9 @@ class MovingAverageStatistics
LIBSTATISTICS_COLLECTOR_PUBLIC
MovingAverageStatistics() = default;

LIBSTATISTICS_COLLECTOR_PUBLIC
explicit MovingAverageStatistics(const std::size_t & window_size);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
explicit MovingAverageStatistics(const std::size_t & window_size);
explicit MovingAverageStatistics(std::size_t window_size);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watch out for the extra space:

Suggested change
explicit MovingAverageStatistics(const std::size_t & window_size);
explicit MovingAverageStatistics(std::size_t window_size);

And we could keep the const.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For primitives types, we should always pass by value, not reference.

Signed-off-by: Tatsuro Sakaguchi <[email protected]>
Signed-off-by: Tatsuro Sakaguchi <[email protected]>
@Tacha-S Tacha-S force-pushed the feature/window-size branch from 87c9821 to 74d468c Compare February 25, 2025 01:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable setting window size for MovingAverageStatistics
4 participants