Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node::remove_<subscription, publisher, service, client> #205

Closed
jacquelinekay opened this issue Mar 12, 2016 · 8 comments
Closed

Node::remove_<subscription, publisher, service, client> #205

jacquelinekay opened this issue Mar 12, 2016 · 8 comments

Comments

@jacquelinekay
Copy link
Contributor

Node has several functions for creating entities (subscription, publisher, service, client, timer) but not for removing them. This seems like an oversight. I think we should add remove functions, and entities should also remove themselves from Node in their destructor.

@wjwwood
Copy link
Member

wjwwood commented Mar 13, 2016

The opposite of create is not remove... so at least I think the names of the functions should be destroy if you're going to have them.

Since they are scoped and the callback group objects which keep track of them store them as weak pointers:

https://github.com/ros2/rclcpp/blob/master/rclcpp/include/rclcpp/callback_group.hpp#L100

So when they are destroyed, they are effectively removed from any tracking.

@wjwwood
Copy link
Member

wjwwood commented Mar 13, 2016

Reading more of the source (and remembering more) I think the idea is that there should not be remove or destroy functions, but I think we are missing some clean up which should happen in the destructors of these things, for example they might ought to wake up any blocking wait calls so the wait set can be remade without the recently destroyed objects. Like here:

https://github.com/ros2/rclcpp/blob/master/rclcpp/src/rclcpp/subscription.cpp#L41-L60

@jacquelinekay
Copy link
Contributor Author

Hmm, yeah, when I originally created this ticket I might have also been thinking of functions to remove a subscription/client/service from a node and manage the state in the node that tracks those entities (like this https://github.com/ros2/rclcpp/blob/master/rclcpp/include/rclcpp/node.hpp#L273-L276), without destroying the node itself.

@wjwwood
Copy link
Member

wjwwood commented Mar 13, 2016

Searching, those might be dead code now:

Searching 71 files for "number_of_subscriptions_" (case sensitive)

/Users/william/ros2_ws/src/ros2/rclcpp/rclcpp/include/rclcpp/node.hpp:
  271    CallbackGroupWeakPtrList callback_groups_;
  272  
  273:   size_t number_of_subscriptions_;
  274    size_t number_of_timers_;
  275    size_t number_of_services_;

/Users/william/ros2_ws/src/ros2/rclcpp/rclcpp/include/rclcpp/node_impl.hpp:
  243      default_callback_group_->add_subscription(sub_base_ptr);
  244    }
  245:   number_of_subscriptions_++;
  246    return sub;
  247  }

/Users/william/ros2_ws/src/ros2/rclcpp/rclcpp/src/rclcpp/node.cpp:
   36    bool use_intra_process_comms)
   37  : name_(node_name), context_(context),
   38:   number_of_subscriptions_(0), number_of_timers_(0), number_of_services_(0),
   39    use_intra_process_comms_(use_intra_process_comms)
   40  {

3 matches across 3 files

It is declared, initialized, and incremented, but otherwise never referenced or decremented anywhere in rclcpp.

@jacquelinekay
Copy link
Contributor Author

oh, interesting. and they are private. We should definitely clean that up.

@Karsten1987
Copy link
Contributor

@wjwwood is that still an ongoing discussion? It looks to me as if using shared_ptr/weak_ptr doesn't require any destroy functions.

@wjwwood
Copy link
Member

wjwwood commented Feb 26, 2018

Have the functions mentioned been removed? If not then I’d say the task in this issue is not done yet. I don’t think any more discussion needs to be done.

nnmm pushed a commit to ApexAI/rclcpp that referenced this issue Jul 9, 2022
* Document rcl_take_response() populates the header
DensoADAS pushed a commit to DensoADAS/rclcpp that referenced this issue Aug 5, 2022
* Introduce new SequentialReader interface

Signed-off-by: Anas Abou Allaban <[email protected]>

Introduce new SequentialReader interface

Signed-off-by: Anas Abou Allaban <[email protected]>

Introduce new SequentialReader interface

Signed-off-by: Anas Abou Allaban <[email protected]>

Introduce new SequentialReader interface

Signed-off-by: Anas Abou Allaban <[email protected]>

* Address commments:
- Rewrite history
- Move sequential reader implementation to header/source
- Change namespaces
- Linting

Signed-off-by: Anas Abou Allaban <[email protected]>

* Add visiblity control header

Signed-off-by: Anas Abou Allaban <[email protected]>

* Address structural review feedback

Signed-off-by: Prajakta Gokhale <[email protected]>

* Remove extraneous newline

Signed-off-by: Prajakta Gokhale <[email protected]>

* Add new BaseReaderInterface

* Add new reader interface
* Use the interface in sequential reader

Signed-off-by: Prajakta Gokhale <[email protected]>

* Remove extra newline

Signed-off-by: Prajakta Gokhale <[email protected]>

* Final reader class implementation (ros2#4)

* final reader class

Signed-off-by: Karsten Knese <[email protected]>

* adaptations for rosbag2_transport

Signed-off-by: Karsten Knese <[email protected]>

* address review comments

Signed-off-by: Karsten Knese <[email protected]>

* Make BaseReaderInterface public

Signed-off-by: Prajakta Gokhale <[email protected]>

* Rebase on writer changes

Signed-off-by: Karsten Knese <[email protected]>

* Introduce new SequentialReader interface

Signed-off-by: Anas Abou Allaban <[email protected]>

Introduce new SequentialReader interface

Signed-off-by: Anas Abou Allaban <[email protected]>

Introduce new SequentialReader interface

Signed-off-by: Anas Abou Allaban <[email protected]>

Introduce new SequentialReader interface

Signed-off-by: Anas Abou Allaban <[email protected]>

* Address commments:
- Rewrite history
- Move sequential reader implementation to header/source
- Change namespaces
- Linting

Signed-off-by: Anas Abou Allaban <[email protected]>

* Final reader class implementation (ros2#4)

* final reader class

Signed-off-by: Karsten Knese <[email protected]>

* adaptations for rosbag2_transport

Signed-off-by: Karsten Knese <[email protected]>

* address review comments

Signed-off-by: Karsten Knese <[email protected]>

* rebase

Signed-off-by: Karsten Knese <[email protected]>

* structurial changes for rosbag2

Signed-off-by: Karsten Knese <[email protected]>

* rosbag2_transport adaptations

Signed-off-by: Karsten Knese <[email protected]>

* fixes for rebasing

Signed-off-by: Karsten Knese <[email protected]>

* pragma for windows

Signed-off-by: Karsten Knese <[email protected]>

* remove unused file

Signed-off-by: Karsten Knese <[email protected]>
@clalancette
Copy link
Contributor

It looks to me like everything has been done here (with destructors), and number_of_subscriptions was also removed. So closing this out.

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

No branches or pull requests

4 participants