Repository navigation
Intentionally copy rclpy:: objects instead of having RclPtrs structs - #773
Merged
Merged
Conversation
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
Signed-off-by: Shane Loretz <[email protected]>
ahcorde
approved these changes
Apr 23, 2021
ahcorde
pushed a commit
that referenced
this pull request
Apr 23, 2021
…773) * Rough pass converting everything Signed-off-by: Shane Loretz <[email protected]> * Fixes to get copy destruction order working Signed-off-by: Shane Loretz <[email protected]> * Fix qos_event test flakiness Signed-off-by: Shane Loretz <[email protected]> Signed-off-by: ahcorde <[email protected]>
ahcorde
added a commit
that referenced
this pull request
Apr 28, 2021
* convert Node and Context to use C++ Classes Signed-off-by: ahcorde <[email protected]> * Added feedback Signed-off-by: ahcorde <[email protected]> * Added feedback Signed-off-by: ahcorde <[email protected]> * Implement solution 1 Signed-off-by: ahcorde <[email protected]> * Prevent double early destruction of destroyable This along with an extra call to `destroy_node()` in `Node.__del__` was causing a segfault in the test_publisher test. The problem is `destroy_when_not_in_use()` was being called twice, and the second time is now a problem because rcl_ptrs_ is dereferenced in the qos_event destroy() method. Signed-off-by: Shane Loretz <[email protected]> * Remove unnecessary Node.__del__ This should not be required. If it is, it means there's a bug that shows when the Node is garbage collected. Signed-off-by: Shane Loretz <[email protected]> * Fix order of pointers in RclPtrs structs The order of the pointers in the RclPtrs structs is important. Things at the bottom are destroyed first, so children must be placed underneath the parent's that must be kept alive. Signed-off-by: Shane Loretz <[email protected]> * Intentionally copy rclpy:: objects instead of having RclPtrs structs (#773) * Rough pass converting everything Signed-off-by: Shane Loretz <[email protected]> * Fixes to get copy destruction order working Signed-off-by: Shane Loretz <[email protected]> * Fix qos_event test flakiness Signed-off-by: Shane Loretz <[email protected]> Signed-off-by: ahcorde <[email protected]> * MacOS warning Signed-off-by: ahcorde <[email protected]> * added feedback and removed some files Signed-off-by: ahcorde <[email protected]> * Create only one context otherwise throw a exception Signed-off-by: ahcorde <[email protected]> Co-authored-by: Shane Loretz <[email protected]> Co-authored-by: Shane Loretz <[email protected]>
sloretz
added a commit
that referenced
this pull request
Apr 28, 2021
* Convert Publisher and Subscription to use C++ Classes (#756) * Convert Publisher and Subscription to C++ Classes Signed-off-by: ahcorde <[email protected]> * Fixed destructor issues Signed-off-by: ahcorde <[email protected]> * [pub/sub 756 addition] use std::shared_ptr holder type and shared_from_this (#757) * Use std::shared_ptr holder type Signed-off-by: Shane Loretz <[email protected]> * Use shared_from_this for pub/sub Signed-off-by: Shane Loretz <[email protected]> * Make Timer keep Clock wrapper Signed-off-by: Shane Loretz <[email protected]> * Fixed publisher and subscription destructors Signed-off-by: ahcorde <[email protected]> * Added feedback Signed-off-by: ahcorde <[email protected]> * Fixed docs Signed-off-by: ahcorde <[email protected]> Co-authored-by: Shane Loretz <[email protected]> * Use py::class_ for rcl_action_goal_handle_t (#751) * Class object Signed-off-by: Greg Balke <[email protected]> * Python adjustments Signed-off-by: Greg Balke <[email protected]> * Adjustments to server and enum Signed-off-by: Greg Balke <[email protected]> * Adjust destructor calls Signed-off-by: Greg Balke <[email protected]> * Clear out destructor Signed-off-by: Greg Balke <[email protected]> * Do what rclcpp did Signed-off-by: Greg Balke <[email protected]> * Remove iostream (used for debugging) Signed-off-by: Greg Balke <[email protected]> * Matching upstream changes Signed-off-by: Greg Balke <[email protected]> * Convert ActionClient to use C++ classes (#759) * Convert ActionClient to use C++ classes Signed-off-by: ahcorde <[email protected]> * Added feedback Signed-off-by: ahcorde <[email protected]> * Added convert_from_py to utils Signed-off-by: ahcorde <[email protected]> * improved docs Signed-off-by: ahcorde <[email protected]> * nits to adapt the code to pybind11 Signed-off-by: ahcorde <[email protected]> * throw a exception in convert_from_py Signed-off-by: ahcorde <[email protected]> * Fixed docs Signed-off-by: ahcorde <[email protected]> * Convert ActionServer to use C++ Classes (#766) * Convert ActionServer to use C++ Classes Signed-off-by: ahcorde <[email protected]> * Fixed Test_action_server Signed-off-by: ahcorde <[email protected]> * Improved docs Signed-off-by: ahcorde <[email protected]> * Improved docs and minor fixes Signed-off-by: ahcorde <[email protected]> * Convert WaitSet to use C++ Classes (#769) * Convert WaitSet to use C++ Classes Signed-off-by: ahcorde <[email protected]> * added feedback Signed-off-by: ahcorde <[email protected]> * Removed unused structs (#770) Signed-off-by: ahcorde <[email protected]> * Convert Guardcondition to use C++ classes (#772) * Convert Guardcondition to use C++ classes Signed-off-by: ahcorde <[email protected]> * make destroy guard condition capsule function private Signed-off-by: ahcorde <[email protected]> * Pybind11 action goal handle nitpicks (#767) * Add GoalEvent back to module Signed-off-by: Shane Loretz <[email protected]> * self._goal -> self._goal_handle Signed-off-by: Shane Loretz <[email protected]> * Remove unused API Signed-off-by: Shane Loretz <[email protected]> Co-authored-by: ahcorde <[email protected]> * Pybind11 actionserver nitpicks and docblock improvements (#774) Signed-off-by: ahcorde <[email protected]> * Convert Node and Context to use C++ Classes (#771) * convert Node and Context to use C++ Classes Signed-off-by: ahcorde <[email protected]> * Added feedback Signed-off-by: ahcorde <[email protected]> * Added feedback Signed-off-by: ahcorde <[email protected]> * Implement solution 1 Signed-off-by: ahcorde <[email protected]> * Prevent double early destruction of destroyable This along with an extra call to `destroy_node()` in `Node.__del__` was causing a segfault in the test_publisher test. The problem is `destroy_when_not_in_use()` was being called twice, and the second time is now a problem because rcl_ptrs_ is dereferenced in the qos_event destroy() method. Signed-off-by: Shane Loretz <[email protected]> * Remove unnecessary Node.__del__ This should not be required. If it is, it means there's a bug that shows when the Node is garbage collected. Signed-off-by: Shane Loretz <[email protected]> * Fix order of pointers in RclPtrs structs The order of the pointers in the RclPtrs structs is important. Things at the bottom are destroyed first, so children must be placed underneath the parent's that must be kept alive. Signed-off-by: Shane Loretz <[email protected]> * Intentionally copy rclpy:: objects instead of having RclPtrs structs (#773) * Rough pass converting everything Signed-off-by: Shane Loretz <[email protected]> * Fixes to get copy destruction order working Signed-off-by: Shane Loretz <[email protected]> * Fix qos_event test flakiness Signed-off-by: Shane Loretz <[email protected]> Signed-off-by: ahcorde <[email protected]> * MacOS warning Signed-off-by: ahcorde <[email protected]> * added feedback and removed some files Signed-off-by: ahcorde <[email protected]> * Create only one context otherwise throw a exception Signed-off-by: ahcorde <[email protected]> Co-authored-by: Shane Loretz <[email protected]> Co-authored-by: Shane Loretz <[email protected]> Co-authored-by: Alejandro Hernández Cordero <[email protected]> Co-authored-by: Greg Balke <[email protected]> Co-authored-by: ahcorde <[email protected]>
sloretz
added a commit
that referenced
this pull request
Apr 28, 2021
* convert Node and Context to use C++ Classes Signed-off-by: ahcorde <[email protected]> * Added feedback Signed-off-by: ahcorde <[email protected]> * Added feedback Signed-off-by: ahcorde <[email protected]> * Implement solution 1 Signed-off-by: ahcorde <[email protected]> * Prevent double early destruction of destroyable This along with an extra call to `destroy_node()` in `Node.__del__` was causing a segfault in the test_publisher test. The problem is `destroy_when_not_in_use()` was being called twice, and the second time is now a problem because rcl_ptrs_ is dereferenced in the qos_event destroy() method. Signed-off-by: Shane Loretz <[email protected]> * Remove unnecessary Node.__del__ This should not be required. If it is, it means there's a bug that shows when the Node is garbage collected. Signed-off-by: Shane Loretz <[email protected]> * Fix order of pointers in RclPtrs structs The order of the pointers in the RclPtrs structs is important. Things at the bottom are destroyed first, so children must be placed underneath the parent's that must be kept alive. Signed-off-by: Shane Loretz <[email protected]> * Intentionally copy rclpy:: objects instead of having RclPtrs structs (#773) * Rough pass converting everything Signed-off-by: Shane Loretz <[email protected]> * Fixes to get copy destruction order working Signed-off-by: Shane Loretz <[email protected]> * Fix qos_event test flakiness Signed-off-by: Shane Loretz <[email protected]> Signed-off-by: ahcorde <[email protected]> * MacOS warning Signed-off-by: ahcorde <[email protected]> * added feedback and removed some files Signed-off-by: ahcorde <[email protected]> * Create only one context otherwise throw a exception Signed-off-by: ahcorde <[email protected]> Co-authored-by: Shane Loretz <[email protected]> Co-authored-by: Shane Loretz <[email protected]>
sloretz
added a commit
that referenced
this pull request
Jun 23, 2021
* convert Node and Context to use C++ Classes Signed-off-by: ahcorde <[email protected]> * Added feedback Signed-off-by: ahcorde <[email protected]> * Added feedback Signed-off-by: ahcorde <[email protected]> * Implement solution 1 Signed-off-by: ahcorde <[email protected]> * Prevent double early destruction of destroyable This along with an extra call to `destroy_node()` in `Node.__del__` was causing a segfault in the test_publisher test. The problem is `destroy_when_not_in_use()` was being called twice, and the second time is now a problem because rcl_ptrs_ is dereferenced in the qos_event destroy() method. Signed-off-by: Shane Loretz <[email protected]> * Remove unnecessary Node.__del__ This should not be required. If it is, it means there's a bug that shows when the Node is garbage collected. Signed-off-by: Shane Loretz <[email protected]> * Fix order of pointers in RclPtrs structs The order of the pointers in the RclPtrs structs is important. Things at the bottom are destroyed first, so children must be placed underneath the parent's that must be kept alive. Signed-off-by: Shane Loretz <[email protected]> * Intentionally copy rclpy:: objects instead of having RclPtrs structs (#773) * Rough pass converting everything Signed-off-by: Shane Loretz <[email protected]> * Fixes to get copy destruction order working Signed-off-by: Shane Loretz <[email protected]> * Fix qos_event test flakiness Signed-off-by: Shane Loretz <[email protected]> Signed-off-by: ahcorde <[email protected]> * MacOS warning Signed-off-by: ahcorde <[email protected]> * added feedback and removed some files Signed-off-by: ahcorde <[email protected]> * Create only one context otherwise throw a exception Signed-off-by: ahcorde <[email protected]> Co-authored-by: Shane Loretz <[email protected]> Co-authored-by: Shane Loretz <[email protected]> Signed-off-by: Shane Loretz <[email protected]>
sloretz
added a commit
that referenced
this pull request
Aug 11, 2021
* convert Node and Context to use C++ Classes Signed-off-by: ahcorde <[email protected]> * Added feedback Signed-off-by: ahcorde <[email protected]> * Added feedback Signed-off-by: ahcorde <[email protected]> * Implement solution 1 Signed-off-by: ahcorde <[email protected]> * Prevent double early destruction of destroyable This along with an extra call to `destroy_node()` in `Node.__del__` was causing a segfault in the test_publisher test. The problem is `destroy_when_not_in_use()` was being called twice, and the second time is now a problem because rcl_ptrs_ is dereferenced in the qos_event destroy() method. Signed-off-by: Shane Loretz <[email protected]> * Remove unnecessary Node.__del__ This should not be required. If it is, it means there's a bug that shows when the Node is garbage collected. Signed-off-by: Shane Loretz <[email protected]> * Fix order of pointers in RclPtrs structs The order of the pointers in the RclPtrs structs is important. Things at the bottom are destroyed first, so children must be placed underneath the parent's that must be kept alive. Signed-off-by: Shane Loretz <[email protected]> * Intentionally copy rclpy:: objects instead of having RclPtrs structs (#773) * Rough pass converting everything Signed-off-by: Shane Loretz <[email protected]> * Fixes to get copy destruction order working Signed-off-by: Shane Loretz <[email protected]> * Fix qos_event test flakiness Signed-off-by: Shane Loretz <[email protected]> Signed-off-by: ahcorde <[email protected]> * MacOS warning Signed-off-by: ahcorde <[email protected]> * added feedback and removed some files Signed-off-by: ahcorde <[email protected]> * Create only one context otherwise throw a exception Signed-off-by: ahcorde <[email protected]> Co-authored-by: Shane Loretz <[email protected]> Co-authored-by: Shane Loretz <[email protected]> Signed-off-by: Shane Loretz <[email protected]>
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 is an alternative to https://github.com/ros2/rclpy/compare/ahcorde/pybind11-node...ahcorde/pybind11-node_option2?expand=1
It implementions option2 from this comment: #771 (comment)
part of #665 via part of #771
This PR intentionally copies the
rclpy::Node,rclpy::Context, etc ... classes instead of copying a shared_ptr to anrclpy::*::RclPtrsstruct.The interesting things in this PR are:
shared_ptr<rcl_*_t>types must not capturethis, because that will always be the pointer to the original instance, but the struct might finally be deleted by a copy instead. Capturing the variables they need (nodein all cases) by value solved this in all cases.test_qos_eventcircumvents the node API to create the events it's testing, meaning the PythonPublisherinstance doesn't have a record of the events existing, so it can't destroy it when the PythonPublisheris destroyed. Now that the QoSEvent properly keeps the publisher and therefore the node alive it was possible for data to leak between tests. callinggc.collect()inTearDownis a quick fix for this.guard_condition.hppwherecontext_was moved above thercl_guard_condition_tmember).rcl_*_tpointers need to beshared_ptrinstead ofunique_ptrso they can be shared with and kept alive by copies in their children.std::variant<Publisher, Subscription>in QoSEvent ... for funrclpy::WaitSetdoesn't need a default constructor