Merged
Conversation
34 tasks
sloretz
requested changes
Apr 2, 2021
rclpy/src/rclpy/timer.cpp
Outdated
| py::object pyclock, py::capsule pycontext, int64_t period_nsec) | ||
| { | ||
| auto clock = clock_handle_->cast<rcl_clock_t *>("rcl_clock_t"); | ||
| clock_handle_ = std::make_shared<rcl_clock_t>(*pyclock.cast<Clock>().rcl_ptr()); |
Contributor
There was a problem hiding this comment.
I looks like this is creating a copy of the clock, but I don't think that's desired. If the original copy of the clock goes out of scope, then the clock will be fini()'d, and the jump callback pointers on the rcl_clock_t itself will point to free'd memory.
Instead, I think Clock should have a method that returns an std::shared_ptr<rcl_clock_t>, maybe
std::shared_ptr<rcl_clock_t>
rcl_shared_ptr()
{
return rcl_clock_
}and then Timer can store that with : clock_handle_(clock.rcl_shared_ptr())
Signed-off-by: ahcorde <ahcorde@gmail.com>
b2b2fc2 to
ce9fa8b
Compare
Contributor
Author
Signed-off-by: ahcorde <ahcorde@gmail.com>
Signed-off-by: ahcorde <ahcorde@gmail.com>
Contributor
Author
sloretz
approved these changes
Apr 2, 2021
Contributor
|
CI LGTM, both windows CMake warnings are in cyclonedds. Merging 🎉 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 PR builds on top of this other PR #745
Related to #665
This converts the Clock functions to a C++ class.
Signed-off-by: ahcorde ahcorde@gmail.com