Ask Your Question

how to delete a subcriber/publisher in rclpy

asked 2020-12-01 21:25:53 -0500

johnconn gravatar image

updated 2020-12-01 21:44:45 -0500

How do I delete publishers and subscriptions with ros2 rclpy?

I tried doing node.destroy_subscription(subscription) and this appears to work,

and this seems to work most of the time, but every once in a while I get the error

The following exception was never retrieved: Tried to use a handle that has been destroyed.

And then my node is broken (pub/subs no longer work and the node's clock gets stuck).

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-12-18 13:15:29 -0500

William gravatar image

Using node.destroy_subscription(subscription) is the "right way" to do things. It seems like you're encountering a bug, could you include a bit more error context (maybe just more of the console output even if it doesn't seem relevant)?

It's also useful to have a minimal example that could replicate the issue.

If you want to open an issue against, I think this would be appropriate given that you're doing the right thing, just getting an unexpected error.

Also, since this question is a bit old (sorry), maybe you solved it already?

edit flag offensive delete link more


I never solved it. I worked around the issue by preventing pub/sub deletion. I was trying to port bondpy to ros2, and the existing implementation would delete pub/sub of the bond whenever the bond died or was deallocated

johnconn gravatar image johnconn  ( 2020-12-21 09:31:14 -0500 )edit

Hi, I am also facing similar issue. Were you able to find any solution?

akashbhavsar gravatar image akashbhavsar  ( 2022-02-23 10:20:37 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-12-01 21:25:53 -0500

Seen: 993 times

Last updated: Dec 18 '20