-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Controllers should not be influenced by time jumps or slew #2012
Conversation
Therefore use rclcpp::GenericRate<std::chrono::steady_clock> instead of rclcpp::Rate Signed-off-by: Martijn Buijs <martijn.buijs@gmail.com>
Thank you for your detailed explanation. After a little bit of digging, I agree with your assessment. |
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.
I'd prefer WallRate since rclcpp gives that to us and makes this code more readable. When I google things, it seems that this is an accurate use of the Wall phrasing. I will merge when WallRate
.
I'm a bit surprised that you found this an accurate use of the term 'wall' then googling. Among the results I ended up at were man pages and cppreference, which both specifically mentioned that these wall clocks can jump. Then I checked how this is done in ROS1 and I found that there also I will change this PR to use Side note: I'm wondering if in the long run it would be a better idea to not use |
Yes, please use the ROS2 provided APIs where they exist to make things more readable. I'd be happy to have it changed to another name if that change is made in rclcpp (I don't really have a strong feeling one way or another). Timers have their roles, but not in the places where you made changes. |
Done. |
Signed-off-by: Martijn Buijs <martijn.buijs@gmail.com>
I'll merge after CI passes |
Codecov Report
@@ Coverage Diff @@
## main #2012 +/- ##
==========================================
- Coverage 84.95% 84.33% -0.62%
==========================================
Files 294 294
Lines 15056 15056
==========================================
- Hits 12791 12698 -93
- Misses 2265 2358 +93
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
* Controllers should not be influenced by time jumps Therefore use rclcpp::GenericRate<std::chrono::steady_clock> instead of rclcpp::Rate Signed-off-by: Martijn Buijs <martijn.buijs@gmail.com> * Change to using `rclcpp::WallRate` for better readability Signed-off-by: Martijn Buijs <martijn.buijs@gmail.com>
* initialize variables in inflation layer (#1970) * Fix zero waypoints crash (#1978) * return if the number of waypoints is zero. * terminate the action. * Succeed action instead of terminating. * Add IsBatteryLow condition node (#1974) * Add IsBatteryLow condition node * Update default battery topic and switch to battery % * Fix test * Switch to sensor_msgs/BatteryState * Add option to use voltage by default or switch to percentage * Add sensor_msgs dependency in package.xml * Make percentage default over voltage * Update parameter list * Initialize inflate_cone_ variable. (#1988) * Initialize inflate_cone_ variable. * initialize inflate_cone_ based on parameter. * Increase the sleep time in the tests makes the costmap test always succeed on my machine. * Add timeouts to all spin_until_future_complete calls (#1998) * Add timeouts to all spin_until_future_complete calls Signed-off-by: Sarthak Mittal <sarthakmittal2608@gmail.com> * Update default timeout value Signed-off-by: Sarthak Mittal <sarthakmittal2608@gmail.com> * Controllers should not be influenced by time jumps or slew (#2012) * Controllers should not be influenced by time jumps Therefore use rclcpp::GenericRate<std::chrono::steady_clock> instead of rclcpp::Rate Signed-off-by: Martijn Buijs <martijn.buijs@gmail.com> * Change to using `rclcpp::WallRate` for better readability Signed-off-by: Martijn Buijs <martijn.buijs@gmail.com> * Fix max path cycles for case where map has larger Y dimension than X dimension (#2017) * Fix max path cycles for case where map has larger Y dimension than X dimension * Improve readability * fix ament_cpplint and ament_uncrustify issues * fix minor cherry pick conflict mistake * bump version to 0.4.4 Co-authored-by: Michael Ferguson <mfergs7@gmail.com> Co-authored-by: Wilco Bonestroo <w.j.bonestroo@saxion.nl> Co-authored-by: Sarthak Mittal <sarthakmittal2608@gmail.com> Co-authored-by: Martijn Buijs <Martijn.buijs@gmail.com> Co-authored-by: justinIRBT <69175069+justinIRBT@users.noreply.github.com>
…ation#2012) * Controllers should not be influenced by time jumps Therefore use rclcpp::GenericRate<std::chrono::steady_clock> instead of rclcpp::Rate Signed-off-by: Martijn Buijs <martijn.buijs@gmail.com> * Change to using `rclcpp::WallRate` for better readability Signed-off-by: Martijn Buijs <martijn.buijs@gmail.com>
Basic Info
Description of contribution in a few bullet points
rclcpp::Rate
is used for controlling the frequency in a few parts of the code.rclcpp::Rate
usesstd::chrono::system_clock
which is meant to represent wall time. Due to unevitable clock drift on the local system in combination with time synchronisation mechnism's like NTP this clock can tick at a slower or faster rate to stay synchronized with the actual wall time or even jump both forwards and backwards in time in case of bigger offsets.rclcpp::Rate
does not have a mechanism to deal with time jumps, so for example if the time jumps backwards 10 seconds, it will wait for 10 seconds plus the configured interval of theRate
.This contribution changes the use of
rclcpp::Rate
torclcpp::GenericRate<std::chrono::steady_clock>
to use the monotonicsteady_clock
instead. This clock never jumps and is better suited for measuring intervals.A possible point of discussion would be why I did not use
rclcpp::WallRate
, which is an alias forrclcpp::GenericRate<std::chrono::steady_clock>
. The reason is that I find the nameWallRate
very misleading, sincesteady_clock
specifically does not follow wall time. In my opinion it should be renamed toSteadyRate
or something like that, but that's a different discussion.Description of documentation updates required from your changes
N/A. (?)