vectorgrp / sil-kit

Vector SIL Kit – Open-Source Library for Connecting Software-in-the-Loop Environments
https://vectorgrp.github.io/sil-kit-docs
MIT License
107 stars 32 forks source link

Removing subscriber/publisher #129

Closed kocho1984 closed 1 month ago

kocho1984 commented 1 month ago

Is there a way to delete subscriber/publisher which were created with CreateDataSubscriber/CreateDataPublisher methods?

Let's assume that I don't want to be subscibed anymore. How to unsubscibe? Can I just delete them with delete operator?

VDanielEdwards commented 1 month ago

Hello @kocho1984, there is no way to delete any 'controller' in SIL Kit after it has been created with any of the Create... methods on the IParticipant interface.

You can not unsubscribe when you use a publisher/subscriber pair.

I hope this helps!

kocho1984 commented 1 month ago

Hi @VDanielEdwards,

I appreciate you quick response.

OK, just to make sure: once subscribed, there is no way to stop receiving messages on already subscribed topic?

I also couldn't find any method to remove a participant. So, is the only way to stop receiving messages on a subscribed topic by calling Stop from ILifecycleService?

VDanielEdwards commented 1 month ago

Yes that is correct, there is no way to stop receiving messages when a publisher and subscriber in the same simulation match (topic, media type, and labels).

A participant is fully removed (and disconnected) from the system if you destroy the IParticipant object, which is initially returned as a std::unique_ptr<IParticipant> from the CreateParticipant function. If you use a a lifecycle it is a good idea to call the ILifecycleService::Stop method, prior to destroying the IParticipant.

Please note that 'autonomous' participants (i.e., using OperationMode::Autonomous) can leave and re-join a simulation by creating a new participant object with the same participant name after the old participant object has been destroyed.

EDIT(VDanielEdwards): typo EDIT(VDanielEdwards): clarified the re-joining