forked from ros2/rclcpp
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup time source object lifetimes (ros2#1867)
* Small cleanups in TimeSource. Simplify some code, and also make sure to throw an exception when use_sim_time is not of type bool. Also add a test for the latter. * Remove the sim_time_cb_handler. It was originally used to make sure that someone didn't change the 'use_sim_time' type from boolean to something else. But since the parameters interface now does that automatically for us, we don't need the explicit check here. I can think of one situation that this allows that wasn't allowed before. If the user defined 'use_sim_time' as a parameter override when constructing a node, and the type is bool, and they also defined the parameters as 'dynamic_typing', then this callback will still have effect. But presumably if the user went out of their way to change the parameter to dynamic_typing, they are trying to do something esoteric and so we should just let them. * ClocksState does not need to be a pointer. Instead, make it a regular member variable. That lets us get rid of all of the special handling for when it is a weak_ptr or not. It's lifetime is now just that of NodeState. * Stop using NodeState as a weak_ptr in the captures. This ended up causing the lifetime of the object to be weird. Instead, just capture 'this' which is sufficient. * Make sure destroy_clock_sub is first. * Switch to using just a regular object. Windows objects to trying to do "make_shared" in the RCLCPP macro, so just switch to a normal object here. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
- Loading branch information
1 parent
bb37b31
commit d1c59eb
Showing
3 changed files
with
102 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters