Closed TimoKettunen closed 2 years ago
It seems that there is a check missing in ros2cs in the Wait (checking whether subscription was disposed already, with a locked sync). This would cause a runtime error to propagate to R2FU primary component and it would be unloaded - meaning no new messages can arrive to (any) subscription.
I will investigate and fix this, thank you for raising the issue! Of course now you can also try it yourself - I would look in the WaitSet.cs file and add this check before line 80 (check whether subscription was disposed). It looks like we overlooked it during refactoring.
Would you mind correcting the issue title to be "Calling Dispose() on Subscriber causes RuntimeError".
The fact that Unity handles MonoBehavior exceptions by unloading the behavior is standard - and this is what "breaks" R2FU since the main component (including the spinning) is no longer running.
The fix is quick but I would like to add a test for the case as well and we currently are preoccupied with ROS World.
@TimoKettunen you could wait for us to get some bandwidth (perhaps next week), but of course a PR is very welcome!
I fixed the title. We are busy too so we will wait until you can fix it next week or so.
@TimoKettunen this is fixed should work for you now, take a look at the merge request by @kielczykowski-rai - he also added some tests for this case
Issue
Calling Dispose for subscription breaks something in the framework, causing errors in log and preventing subsequent subscriptions.
Ways to reproduce:
Setup Unity project with plugins as instructed. With Unity code below (only essential code shown), start terminal and give command
ros2 topic pub mytopic std_msgs/msg/String "data: 'hello'"
When OnStartButtonClicked is called, messages are printed in log as expected. When OnStopButtonClicked is called, messages stop but in log is printed:If OnStartButtonClicked is called again, no messages are received anymore. This happens with standard and custom types in same way.
Full stack trace