betfsm_ros.TopicEventReceiver
Thread-safe event queue for recieving ROS2 String messages
Messages are received in a queue with limited size
Functions for polling the queue, possibly with a max_age parameters to avoid stale events.
No priorities. Multithread save.
clear()
Clears the qeueue
get_instance(node, topic_name, queue_size=10)
classmethod
One singleton queue per topic.
| Parameters: |
|
|---|
Returns: Singleton instance of EventQueueSubscriber.
has_event(target_strings)
Looks for an event in the queue that matches one of the target_strings. Reads from the oldest to the newest element in the queueu. Returns the matching event and None if no event matches. It does not consume the matching event.
has_recent_event(target_strings, max_age_seconds)
Looks for an event in the queue that matches one of the target_strings.
Reads from the oldest to the newest element in the queueu.
Returns the matching event and None if no event matches.
It only returns events that are at most max_age_seconds old.
This can be useful to avoid stale events.
It does not consume the matching event.
log_queue(max_items=20)
Logs a snapshot of queue.
poll_for(target_strings)
Looks for an event in the queue that matches one of the target_strings. Reads from the oldest to the newest element in the queueu. Returns the matching event and None if no event matches. It consumes the matching event.
poll_recent_for(target_strings, max_age_seconds)
Looks for an event in the queue that matches one of the target_strings.
Reads from the oldest to the newest element in the queueu.
Returns the matching event and None if no event matches.
It only returns events that are at most max_age_seconds old.
This can be useful to avoid stale events.
It consumes the matching event.
set_minimum_queue_size(sz)
sets the minimum queue size
size()
Size of the queue