-
Notifications
You must be signed in to change notification settings - Fork 91
Description
Feature request
Feature description
The current implementation of WaitForTopics assumes that the node under test publishes messages without any external stimulus. But it might be that a node only publishes a topic if it received a certain stimulus, like receiving a message or a request.
In other words, let us image a node acting as both subscriber and publisher, with an input topic (subscriber) and an output topic (publisher). The input is received and processed and the output is emitted.
In this case, WaitForTopics would be waiting for a topic without any means to actually trigger it.
Implementation considerations
If the input topic is injected into the test node before calling WaitForTopics::wait(), the output topic might be emitted before the wait() call and it is not intercepted by wait(). On the other hand, if the input topic is injected after the call to wait(), obviously wait() cannot intercept the output.
One solution would be to inject a callback function into WaitForTopics that can take care of feeding the node under test with the needed input to produce the desired output.
Another solution is to provide a synchronization mechanism, such that the caller can create a dedicated thread to generate the input.
In any case, the input should be generated just after the subscribers have been started
def wait(self):
self.__ros_node.start_subscribers(self.topic_tuples)
# <<<<<<<<< HERE >>>>>>>>>>
return self.__ros_node.msg_event_object.wait(self.timeout)Similarly to the issue #346 I am available to develop a solution if you think this feature is worth the effort.