Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes some issues with the
ThrottledCallback
logic:last_called_time_
attribute being initialized to zero. But instead of callinglast_called_time_.isZero()
to check for that, I was calling!last_called_time_.isValid()
, which doesn't check for zero at all:https://github.com/ros/roscpp_core/blob/b2a9c0affcaacb510b6e9ec6e46b595bb145d3c9/rostime/src/time.cpp#L324-L327
last_called_time_
tonow
when the message is kept, this change increments it by thethrottle_period_
. In other words, the last called time is updated to the expected called time instead of the actual one. This is important to actually throttle at the desired period/frequency. I found a similar issue recently in Update last publish time adding period clearpathrobotics/ros_controllers#62 . My initial implementation here was following thetopic_tools throttle
one: https://github.com/ros/ros_comm/blob/c7f7598e8a49b1b4eb6f3e42f698147e151a811d/tools/topic_tools/src/throttle.cpp#L134-L138, but I believe the approach of this PR is more accurate.last_called_time_
still have to be set tonow
the first time it's called though