Skip to content

Convert Clock to use a C++ Class#749

Merged
sloretz merged 4 commits intomasterfrom
ahcorde/pybind-clock_ontop
Apr 2, 2021
Merged

Convert Clock to use a C++ Class#749
sloretz merged 4 commits intomasterfrom
ahcorde/pybind-clock_ontop

Conversation

@ahcorde
Copy link
Copy Markdown
Contributor

@ahcorde ahcorde commented Apr 1, 2021

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

@ahcorde ahcorde requested a review from sloretz April 1, 2021 15:48
@ahcorde ahcorde mentioned this pull request Apr 1, 2021
34 tasks
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());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahcorde mind addressing this comment?

@delete-merged-branch delete-merged-branch bot deleted the branch master April 2, 2021 14:57
Signed-off-by: ahcorde <ahcorde@gmail.com>
@ahcorde ahcorde force-pushed the ahcorde/pybind-clock_ontop branch from b2b2fc2 to ce9fa8b Compare April 2, 2021 15:57
@ahcorde ahcorde changed the base branch from ahcorde/pybind-timer to master April 2, 2021 15:59
@ahcorde ahcorde requested a review from sloretz April 2, 2021 15:59
@ahcorde
Copy link
Copy Markdown
Contributor Author

ahcorde commented Apr 2, 2021

CI (build: --packages-above-and-dependencies rclpy test: --packages-above rclpy)

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

ahcorde added 2 commits April 2, 2021 19:37
Signed-off-by: ahcorde <ahcorde@gmail.com>
Signed-off-by: ahcorde <ahcorde@gmail.com>
@ahcorde
Copy link
Copy Markdown
Contributor Author

ahcorde commented Apr 2, 2021

CI (build: --packages-above-and-dependencies rclpy test: --packages-above rclpy)

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@sloretz
Copy link
Copy Markdown
Contributor

sloretz commented Apr 2, 2021

CI LGTM, both windows CMake warnings are in cyclonedds. Merging 🎉

@sloretz sloretz merged commit 9c1b80a into master Apr 2, 2021
@delete-merged-branch delete-merged-branch bot deleted the ahcorde/pybind-clock_ontop branch April 2, 2021 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants