yasmin_viewer.yasmin_viewer_pub module

class yasmin_viewer.yasmin_viewer_pub.YasminViewerPub(fsm_name: str, fsm: yasmin.StateMachine, rate: int = 4, node: rclpy.node.Node | None = None)

Bases: object

A class to publish the state of a Finite State Machine (FSM) for visualization.

Attributes:

_node (Node): The ROS 2 node instance used for publishing. _fsm (StateMachine): The finite state machine to be published. _fsm_name (str): The name of the finite state machine. pub: The publisher for the state machine messages. _timer: A timer to periodically publish the FSM state.

Methods:

parse_transitions(transitions): Converts a dictionary of transitions to a list of TransitionMsg. parse_state(state_name, state_info, states_list, parent): Parses a state and its children recursively. _publish_data(): Publishes the current state of the FSM.

parse_state(state_name: str, state_info: Dict[str, str], states_list: List[yasmin_msgs.msg.State], parent: int = -1) None

Recursively parses a state and its transitions, adding the resulting StateMsg to the states list.

Args:

state_name (str): The name of the state. state_info (Dict[str, str]): Information about the state, including its transitions. states_list (List[StateMsg]): A list to which the parsed StateMsg will be appended. parent (int, optional): The ID of the parent state. Defaults to -1.

Returns:

None

parse_transitions(transitions: Dict[str, str]) List[yasmin_msgs.msg.Transition]

Converts a dictionary of transitions into a list of TransitionMsg.

Args:

transitions (Dict[str, str]): A dictionary where keys are outcome names and values are state names.

Returns:

List[TransitionMsg]: A list of TransitionMsg representing the FSM transitions.