Core API State Templates

CallbacksState

The CallbacksState template is used for creating lambda function callbacks and is specified as follows:

Template: CallbacksState
Description: SMACH state that defines callbacks that operate on userdata.
Language: Python
Framework: SMACH
Type: State
Extends:
    State
Variables:
    callbacks: Either callback function names or backtick-wrapped lambda function strings.
        Type: dict of str

    input_keys (optional): The userdata input keys needed for the request callback.
        Type: list of str

    output_keys (optional): The userdata output keys needed for the response callback.
        Type: list of str

Outcomes:
    succeeded

ConditionalOutcomeState

The ConditionalOutcomeState template is used for conditionally selecting an outcome and is specified as follows:

Template: ConditionalOutcomeState
Description: A SMACH state that conditionally selects an outcome from a list of possible outcomes if its corresponding callback returns True.
Language: Python
Framework: SMACH
Type: State
Extends:
    State
Variables:
    outcomes (optional): The possible outcomes (other than default).
        Type: list of str

    callbacks (optional): Either callback function names or backtick-wrapped lambda function strings defining conditions that return True for corresponding outcomes.
        Type: dict of str

    input_keys (optional): The names of the userdata input keys needed for the outcome conditional callbacks.
        Type: list of str

Output Keys:
    outcome: The selected outcome is stored in the outcome output_key.
        Type: str

Outcomes:
    default: The default outcome, selected if no other outcome is selected, e.g. if all callbacks return False.
        Type: str

DeleteFileState

The DeleteFileState template is used deleting files from the file system and is specified as follows:

Template: DeleteFileState
Description: SMACH state that deletes specified files from the file system.
Language: Python
Framework: SMACH
Type: State
Extends:
    State
Variables:
    callbacks: Either callback function names or backtick-wrapped lambda functions for, e.g. modifying the filenames.
        Type: dict of str

    input_keys (optional): The userdata input keys, e.g. needed by the optionally specified callbacks.
        Type: list of str

    output_keys (optional): The userdata output keys, e.g. needed by the optionally specified callbacks.
        Type: list of str

Input Keys:
    file: The file, files or file specification for deletion. A deletion loop is called on glob.glob(userdata.file).
        Type: str

Outcomes:
    succeeded
    aborted

PrintUserdataState

The PrintUserdataState template is used for printing userdata entries to standard output and is specified as follows:

Template: PrintUserdataState
Description: SMACH state that prints the values of userdata input_keys to standard output.
Language: Python
Framework: SMACH
Type: State
Extends:
    State
Variables:
    input_keys: The names of the userdata input keys to be printed.
        Type: list of str

    output_keys (optional): The names of the userdata output keys corresponding to each optionally specified callback function.
        Type: list of str

    callbacks (optional): Either callback function names or backtick-wrapped lambda functions for possible modifications to the printing procedure.
        Type: dict of str

    outcomes (optional): The possible outcomes.
        Type: list of str

Outcomes:
    succeeded

RandomOutcomeState

The RandomOutcomeState template is used for selecting a random outcome from a specified list of outcomes and is specified as follows:

Template: RandomOutcomeState
Description: SMACH state randomly selects an outcome from a list of possible outcomes.
Language: Python
Framework: SMACH
Type: State
Extends:
    State
Variables:
    input_keys (optional): The names of the userdata input keys to be used by the optionally specified callback functions.
        Type: list of str

    output_keys (optional): The names of the userdata output keys corresponding to each optionally specified callback function.
        Type: list of str

    callbacks (optional): Either callback function names or backtick-wrapped lambda functions for possible modifications to the randomization procedure. The default callback is outcome: '`lambda ud.outcome: random.choice(list(self._outcomes))`'.

        Type: dict of str

    outcomes: The possible outcomes.
        Type: list of str

Input Keys:
    outcome: The selected outcome is stored in the outcome output_key.
        Type: str

Output Keys:
    outcome: The selected outcome is stored in the outcome output_key.
        Type: str

Outcomes:
    succeeded

WriteCSVFileState

The WriteCSVFileState template is used for writing CSV files to the file system and is specified as follows:

Template: WriteCSVFileState
Description: SMACH state that writes a comma-separated values (CSV) file to the file system based on userdata input.
Language: Python
Framework: SMACH
Type: State
Extends:
    State
Variables:
    input_keys: The userdata input keys, e.g. the data_keys to be written to file.
        Type: list of str

    output_keys (optional): The userdata output keys, e.g. needed by the optionally specified callbacks.
        Type: list of str

    callbacks (optional): Either callback function names or backtick-wrapped lambda functions for, e.g. modifying the data_keys.
        Type: dict of str

    delimiter (optional): The symbol to be used to separate data columns in the CSV file. Defaults to `,`.
        Type: list of str

Input Keys:
    file: The CSV file path.
        Type: str

    data_keys: The names of the input_keys to be written to file.
        Type: list of str

Outcomes:
    succeeded
    aborted