|
Python YASMIN (Yet Another State MachINe)
|


Public Member Functions | |
| None | __init__ (self, Type msg_type, str topic_name, Set[str] outcomes, Callable monitor_handler, Union[QoSProfile, int] qos=10, CallbackGroup callback_group=None, int msg_queue=10, Node node=None, int timeout=None, int maximum_retry=3) |
| str | execute (self, Blackboard blackboard) |
| None | cancel_state (self) |
Public Attributes | |
| list | msg_list = [] |
| List to store queued messages. | |
| int | msg_queue = msg_queue |
| Maximum number of messages to queue. | |
Protected Attributes | |
| Callable[[Blackboard, Any], str] | _monitor_handler = monitor_handler |
| Function to handle incoming messages. | |
| Event | _msg_event = Event() |
| Event for message reception. | |
| int | _timeout = timeout |
| Timeout in seconds for message reception. | |
| Node | _node = node |
| Shared pointer to the ROS 2 node. | |
| str | _topic_name = topic_name |
| Name of the topic to monitor. | |
| Subscription | _sub = None |
| Subscription to the ROS 2 topic. | |
| Type | _msg_type = msg_type |
| Union[QoSProfile, int] | _qos = qos |
| CallbackGroup | _callback_group = callback_group |
| int | _maximum_retry = maximum_retry |
| Subscription to the ROS 2 topic. | |
Private Member Functions | |
| None | __callback (self, Any msg) |
Template class to monitor a ROS 2 topic and process incoming messages. This class provides functionality to subscribe to a ROS 2 topic, execute a custom monitoring handler, and return specific outcomes based on the messages received.
| None yasmin_ros.monitor_state.MonitorState.__init__ | ( | self, | |
| Type | msg_type, | ||
| str | topic_name, | ||
| Set[str] | outcomes, | ||
| Callable | monitor_handler, | ||
| Union[QoSProfile, int] | qos = 10, | ||
| CallbackGroup | callback_group = None, | ||
| int | msg_queue = 10, | ||
| Node | node = None, | ||
| int | timeout = None, | ||
| int | maximum_retry = 3 ) |
Construct a new MonitorState with specific QoS, message queue, and timeout.
Args:
msg_type (Type): The type of message to be monitored.
topic_name (str): The name of the topic to monitor.
outcomes (Set[str]): A set of possible outcomes for this state.
monitor_handler (Callable[[Blackboard, Any], str]): A callback handler to process incoming messages.
qos (Union[QoSProfile, int], optional): Quality of Service settings for the topic.
callback_group (CallbackGroup, optional): The callback group for the subscription.
msg_queue (int, optional): The maximum number of messages to queue.
node (Node, optional): The ROS 2 node to use. If None, a default node is created.
timeout (int, optional): The time in seconds to wait for messages before timing out.
maximum_retry (int, optional): Maximum retries of the monitor if it returns timeout. Default is 3.
|
private |
Callback function for receiving messages from the subscribed topic.
Adds the message to msg_list maintaining a maximum queue size of msg_queue.
Args:
msg: The message received from the topic.
| None yasmin_ros.monitor_state.MonitorState.cancel_state | ( | self | ) |
Cancels the current monitor state. This method cancels the monitor if waiting for messages.
| str yasmin_ros.monitor_state.MonitorState.execute | ( | self, | |
| Blackboard | blackboard ) |
Execute the monitoring operation and process the first received message.
Args:
blackboard (Blackboard): A shared pointer to the blackboard for data storage.
Returns:
str: A string outcome indicating the result of the monitoring operation.
|
protected |
|
protected |
Subscription to the ROS 2 topic.
Maximum number of retries.
|
protected |
Function to handle incoming messages.
|
protected |
Event for message reception.
|
protected |
|
protected |
Shared pointer to the ROS 2 node.
|
protected |
|
protected |
Subscription to the ROS 2 topic.
|
protected |
Timeout in seconds for message reception.
|
protected |
Name of the topic to monitor.
| yasmin_ros.monitor_state.MonitorState.msg_list = [] |
List to store queued messages.
| int yasmin_ros.monitor_state.MonitorState.msg_queue = msg_queue |
Maximum number of messages to queue.