-
Notifications
You must be signed in to change notification settings - Fork 21
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
base: rolling
Are you sure you want to change the base?
Add window size #210
Conversation
Signed-off-by: Tatsuro Sakaguchi <[email protected]>
There was a problem hiding this 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:
- 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.
- Tests should be added to cover the case where a window is used (probably in
test/moving_average_statistics/test_moving_average_statistics.cpp
). - Finally: How would an end user use this? In this case, this code is ultimately used in
rclcpp
(seerclcpp::topic_statistics::SubscriptionTopicStatistics
). From looking at the subscription creation code inrclcpp
, there is no way to provide awindow_size
value.- One solution might be to add a
window_size
option toTopicStatisticsOptions
: https://github.com/ros2/rclcpp/blob/9c493c4615aee3b5cbc68e9101b588564869b5dc/rclcpp/include/rclcpp/subscription_options.hpp#L69-L85 - Then this would be used here: https://github.com/ros2/rclcpp/blob/9c493c4615aee3b5cbc68e9101b588564869b5dc/rclcpp/include/rclcpp/create_subscription.hpp#L56
- We have to figure out which statistics this should affect.
- One solution might be to add a
@emersonknapp do you have any thoughts on this?
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]>
ed4d967
to
87c9821
Compare
@@ -52,6 +53,9 @@ class MovingAverageStatistics | |||
LIBSTATISTICS_COLLECTOR_PUBLIC | |||
MovingAverageStatistics() = default; | |||
|
|||
LIBSTATISTICS_COLLECTOR_PUBLIC | |||
explicit MovingAverageStatistics(const std::size_t & window_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explicit MovingAverageStatistics(const std::size_t & window_size); | |
explicit MovingAverageStatistics(std::size_t window_size); |
There was a problem hiding this comment.
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:
explicit MovingAverageStatistics(const std::size_t & window_size); | |
explicit MovingAverageStatistics(std::size_t window_size); |
And we could keep the const
.
There was a problem hiding this comment.
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]>
87c9821
to
74d468c
Compare
I have added a window size to calculate the moving average