ros2_rust icon indicating copy to clipboard operation
ros2_rust copied to clipboard

Creating subscriber after spin doesn't work

Open George-Gi opened this issue 6 months ago • 4 comments

If I haven't created any subscribers before spin and after spin I create a subscriber, triggered by a callback, the subscriber doesn't work, i.e. the subscriber callback is never executed. If I create a random subscriber before spin and then create the desired subscriber after spin, the callback of the desired subscriber works. I googled a bit around and I found this issue for ROS2, but it looked quite old and probably has been fixed. Any ideas on that?

George-Gi avatar May 08 '25 12:05 George-Gi

May I ask why you're creating a subscriber after spinning the node? This feels like an unusual design pattern to me - usually your node has all desired/needed subscribers/publishers/clients/services already created before spinning.

jhdcs avatar May 08 '25 12:05 jhdcs

May I ask why you're creating a subscriber after spinning the node? This feels like an unusual design pattern to me - usually your node has all desired/needed subscribers/publishers/clients/services already created before spinning.

We have a certain infrastructure so that the topics for some subscribers are set on the fly with a service

George-Gi avatar May 08 '25 12:05 George-Gi

Creating subscribers on the fly will work after https://github.com/ros2-rust/ros2_rust/pull/446 is merged, but that's currently blocked on #430 getting approved.

@jhdcs I think this capability will be extremely important for lifecycle node use-cases.

mxgrey avatar May 08 '25 13:05 mxgrey

Creating subscribers on the fly will work after #446 is merged, but that's currently blocked on #430 getting approved.

I knew I was forgetting about something. My apologies. Review has been submitted.

jhdcs avatar May 08 '25 13:05 jhdcs