|
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, int msg_queue=10, Node node=None, int timeout=None) |
| str | execute (self, Blackboard blackboard) |
Public Member Functions inherited from yasmin.state.State | |
| None | __init__ (self, Set[str] outcomes) |
| str | __call__ (self, Blackboard blackboard=None) |
| str | __str__ (self) |
| None | cancel_state (self) |
| bool | is_canceled (self) |
| bool | is_running (self) |
| Set[str] | get_outcomes (self) |
Public Attributes | |
| list | msg_list = [] |
| A set of messages received from the topic. | |
| int | msg_queue = msg_queue |
| The maximum number of messages to retain. | |
| float | time_to_wait = 0.001 |
| Time to wait between checks for messages. | |
| bool | monitoring = False |
| Flag indicating if monitoring is active. | |
Protected Attributes | |
| Callable[[Blackboard, Any], None] | _monitor_handler = monitor_handler |
| Function to handle incoming messages. | |
| int | _timeout = timeout |
| Timeout duration for monitoring. | |
| Node | _node = node |
| The ROS 2 node instance used for subscriptions. | |
| str | _topic_name = topic_name |
| The name of the topic to monitor. | |
| Subscription | _sub |
| Subscription object for the specified topic. | |
Protected Attributes inherited from yasmin.state.State | |
| Set | _outcomes = set() |
| A set of valid outcomes for this state. | |
| bool | _running = False |
| A flag indicating whether the state is currently running. | |
| bool | _canceled = False |
| A flag indicating whether the state has been canceled. | |
Private Member Functions | |
| None | __callback (self, msg) |
MonitorState is a state that monitors messages from a ROS topic.
Attributes:
_node (Node): The ROS 2 node instance used for subscriptions.
_sub (Subscription): Subscription object for the specified topic.
_monitor_handler (Callable[[Blackboard, Any], None]): Function to handle incoming messages.
_topic_name (str): The name of the topic to monitor.
msg_list (List[Any]): A set of messages received from the topic.
msg_queue (int): The maximum number of messages to retain.
time_to_wait (float): Time to wait between checks for messages.
monitoring (bool): Flag indicating if monitoring is active.
_timeout (int): Timeout duration for monitoring.
Exceptions:
None raised directly; timeout is managed via outcome handling.
| 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, | ||
| int | msg_queue = 10, | ||
| Node | node = None, | ||
| int | timeout = None ) |
Initializes the MonitorState.
Parameters:
msg_type (Type): The type of message to be monitored.
topic_name (str): The name of the topic to subscribe to.
outcomes (Set[str]): The set of possible outcomes from the state.
monitor_handler (Callable[[Blackboard, Any], None]): The function to call with the received messages.
qos (Union[QoSProfile, int], optional): Quality of Service profile or depth.
msg_queue (int, optional): Maximum number of messages to store. Default is 10.
node (Node, optional): The ROS node to use. If None, a default node is created.
timeout (int, optional): Timeout in seconds for monitoring before giving up.
Returns:
None
|
private |
Callback function that handles incoming messages.
This method is called when a new message is received on the monitored topic.
Parameters:
msg: The message received from the topic.
Returns:
None
| str yasmin_ros.monitor_state.MonitorState.execute | ( | self, | |
| Blackboard | blackboard ) |
Executes the monitoring state.
This method waits for messages from the monitored topic and processes them using
the specified monitor handler.
Parameters:
blackboard (Blackboard): The blackboard instance that holds shared data.
Returns:
str: The outcome of the monitoring process. Returns TIMEOUT if the monitoring
time exceeds the specified timeout.
Exceptions:
None raised directly; timeouts are handled gracefully.
Reimplemented from yasmin.state.State.
|
protected |
Function to handle incoming messages.
|
protected |
The ROS 2 node instance used for subscriptions.
|
protected |
Subscription object for the specified topic.
|
protected |
Timeout duration for monitoring.
|
protected |
The name of the topic to monitor.
| bool yasmin_ros.monitor_state.MonitorState.monitoring = False |
Flag indicating if monitoring is active.
| yasmin_ros.monitor_state.MonitorState.msg_list = [] |
A set of messages received from the topic.
| int yasmin_ros.monitor_state.MonitorState.msg_queue = msg_queue |
The maximum number of messages to retain.
| yasmin_ros.monitor_state.MonitorState.time_to_wait = 0.001 |
Time to wait between checks for messages.