-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[systems] Add DiagramBuilder overloads for shared_ptr
AddSystem and AddNamedSystem functions are overloaded to allow passing the system via mutable shared_ptr (in addition to mutable unique_ptr). Architecturally, the diagram still maintains exclusive ownership of its children: each child still has a back-pointer to the Diagram (via the SystemParentServiceInterface) so it's not possible to actually "share" a subsystem across multiple diagrams. However, unique_ptr is overly restrictive: it not only denotes exclusive ownership (which is fine), but also demands that resource cleanup is `delete MyClass` (which is insufficient for our Python bindings). We must use a smart pointer type that allows customizing cleanup. We could imagine using unique_ptr whose Deleter was a std::function, but it's simpler to just use shared_ptr. Relatedly, we also adjust the Diagram subclasses PidControlledSystem and RgbdSensorDiscrete to accept the more general shared_ptr (instead of unique_ptr) for their child systems and to use ref_cycle for their pydrake bindings.
- Loading branch information
1 parent
f19d31c
commit 7b55dd6
Showing
15 changed files
with
248 additions
and
97 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
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
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
Oops, something went wrong.