as2fm.scxml_converter.scxml_entries.scxml_ros_base.RosCallback

class as2fm.scxml_converter.scxml_entries.scxml_ros_base.RosCallback(interface_decl: str | RosDeclaration, targets: List[ScxmlTransitionTarget], condition: str | None = None)

Bases: ScxmlTransition

Base class for ROS callbacks in SCXML.

__init__(interface_decl: str | RosDeclaration, targets: List[ScxmlTransitionTarget], condition: str | None = None) None

Constructor of ROS callback.

Parameters:
  • interface_decl – ROS interface declaration to be used in the callback, or its name.

  • targets – A list of targets reachable from this callback.

  • condition – Condition to be met for the callback to be executed.

Methods

__init__(interface_decl, targets[, condition])

Constructor of ROS callback.

add_event(event)

add_targets_to_scxml_sends(events_to_targets)

For each "ScxmlSend" entry in the transition body, add the automata receiving the event.

append_body_executable_entry(exec_entry)

Append a executable body entry if this has only one target.

as_plain_scxml(ros_declarations)

Convert the object to its plain SCXML version.

as_xml()

Convert the ROS callback to an XML element.

check_interface_defined(ros_declarations)

Check if the ROS interface used in the callback exists.

check_valid_ros_instantiations(ros_declarations)

Check if the ROS entries in the callback are correctly defined.

check_validity()

Check if the object is valid.

contains_transition_target(xml_tree)

Check if the children of the ScxmlTransition contain ScxmlTransitionTarget tags.

from_xml_tree(xml_tree)

Create an instance of the class from an XML tree.

get_body()

Get the body of the object.

get_callback_type()

Return the callback type of a specific ROS Callback subclass

get_condition()

Return the condition required to execute this transition (if any).

get_declaration_type()

Get the type of ROS declaration related to the callback.

get_events()

Return the events that trigger this transition (if any).

get_id()

Get the ID of the object.

get_interface_name(interface_decl)

Extract the interface name from either a string or a RosDeclaration.

get_plain_scxml_event(ros_declarations)

Translate the ROS interface name to a plain scxml event.

get_tag_name()

XML tag name for the ROS callback type.

get_targets()

Return all targets belonging to this transition.

has_bt_blackboard_input(bt_ports_handler)

Check if the transition contains references to blackboard inputs.

instantiate_bt_events(instance_id, children_ids)

Instantiate the BT events of this transition.

is_plain_scxml()

Check if the transition is a plain scxml entry and contains only plain scxml.

load_transition_targets_from_xml(xml_tree)

Loads all transition targets contained in the transition-like tags.

make_single_target_transition(...[, ...])

Generate a RosCallback with exactly one target, like in vanilla SCXML.

set_targets(new_targets)

Set the targets of the transition.

set_thread_id(thread_id)

Set the thread ID for the executable entries of this transition.

update_bt_ports_values(bt_ports_handler)

Update the values of potential entries making use of BT ports.

add_targets_to_scxml_sends(events_to_targets: Dict[str, Set[str]])

For each “ScxmlSend” entry in the transition body, add the automata receiving the event.

append_body_executable_entry(exec_entry: ScxmlAssign | ScxmlIf | ScxmlSend)

Append a executable body entry if this has only one target.

If this transition has not exactly one target, this will raise an AssertionError.

as_plain_scxml(ros_declarations: ScxmlRosDeclarationsContainer) ScxmlTransition

Convert the object to its plain SCXML version.

as_xml() Element

Convert the ROS callback to an XML element.

check_interface_defined(ros_declarations: ScxmlRosDeclarationsContainer) bool

Check if the ROS interface used in the callback exists.

check_valid_ros_instantiations(ros_declarations: ScxmlRosDeclarationsContainer) bool

Check if the ROS entries in the callback are correctly defined.

check_validity() bool

Check if the object is valid.

static contains_transition_target(xml_tree: Element) bool

Check if the children of the ScxmlTransition contain ScxmlTransitionTarget tags.

classmethod from_xml_tree(xml_tree: Element) RosCallback

Create an instance of the class from an XML tree.

get_body()

Get the body of the object.

classmethod get_callback_type() CallbackType

Return the callback type of a specific ROS Callback subclass

get_condition() str | None

Return the condition required to execute this transition (if any).

classmethod get_declaration_type() Type[RosDeclaration]

Get the type of ROS declaration related to the callback.

Examples: RosSubscriber, RosPublisher, …

get_events() List[str]

Return the events that trigger this transition (if any).

get_id() str

Get the ID of the object.

classmethod get_interface_name(interface_decl: str | RosDeclaration) str

Extract the interface name from either a string or a RosDeclaration.

Parameters:

interface_decl – The interface declaration to extract the information from.

Returns:

A string providing the unique ROS communication interface name.

get_plain_scxml_event(ros_declarations: ScxmlRosDeclarationsContainer) str

Translate the ROS interface name to a plain scxml event.

classmethod get_tag_name() str

XML tag name for the ROS callback type.

get_targets() List[ScxmlTransitionTarget]

Return all targets belonging to this transition.

has_bt_blackboard_input(bt_ports_handler: BtPortsHandler)

Check if the transition contains references to blackboard inputs.

instantiate_bt_events(instance_id: int, children_ids: List[int]) List[ScxmlTransition]

Instantiate the BT events of this transition.

is_plain_scxml() bool

Check if the transition is a plain scxml entry and contains only plain scxml.

classmethod load_transition_targets_from_xml(xml_tree: Element) List[ScxmlTransitionTarget]

Loads all transition targets contained in the transition-like tags.

classmethod make_single_target_transition(interface_decl: str | RosDeclaration, target: str, condition: str | None = None, body: List[ScxmlAssign | ScxmlIf | ScxmlSend] | None = None) RosCallback

Generate a RosCallback with exactly one target, like in vanilla SCXML.

Parameters:
  • interface_decl – The ROS declaration this Callback refers to.

  • target – The state to transition to once the callback is executed.

  • condition – The condition that enables this callback.

  • body – The operations to execute when running this callback.

set_targets(new_targets: List[ScxmlTransitionTarget])

Set the targets of the transition.

Additionally, calculates potentially remaining probabilities and checks they sum to one.

set_thread_id(thread_id: int) None

Set the thread ID for the executable entries of this transition.

update_bt_ports_values(bt_ports_handler: BtPortsHandler) None

Update the values of potential entries making use of BT ports.