2. rafcontpp.control package¶
2.1. Submodules¶
2.2. rafcontpp.control.execution_controller module¶
-
class
rafcontpp.control.execution_controller.
ExecutionController
(datastore)[source]¶ Bases:
object
The ExecutionController controls the execution of the planning pipeline from mapping up to generating the state machine. It’s structured in two parts: a pre-planning, and a post-planning part.
Parameters: datastore – A datastore, containing all relevant data. -
_ExecutionController__parse_facts_file
()¶ Parses the facts file, and creates a facts representation. This is done here, because there no better place yet. Later on it will be done in a dedicated facts module. TODO delete, and do somewhere else.
Returns: PddlFactsRepresentation: A representation of the parsed facts file.
-
on_execute_post_planning
(planning_successful)[source]¶ This function takes care of the post planning steps in the pipeline, e.g. it triggeres the state machine generation procedure. typically its executed from another thread.
Parameters: planning_successful – True if planning was successful, False otherwise. Returns: void
-
on_execute_pre_planning
()[source]¶ on_execute_pre_planning prepares the Datastore and gets everything ready for the planning process. Therefore it triggeres different modules to map actions with states, loads all available actions and generate a domain file. In the end initiates the Planning Process, and returns its thread.
Returns: InterruptableThread: The planning Thread.
-
2.3. rafcontpp.control.pddl_action_tab_controller module¶
-
class
rafcontpp.control.pddl_action_tab_controller.
PddlActionTabController
(state)[source]¶ Bases:
object
PddlActionTabController, controlls the gui elements of the pddl action tab for each state. it handles the dataflow between this tab, and the semantic section of the state, where the data of this tab is stored in. It also provides some auto fill wizzard for its elements.
Parameters: state – The state, it belongs to. -
_PddlActionTabController__get_requirements
(req_dict)¶ Creates a list with all requirements checked in the gui.
Parameters: req_dict – A dictionary, containing the requirements checkboxes and names as keys. Returns: A list with all requirements checked in the gui.
-
_PddlActionTabController__predicates_auto_complete
(pddl_action, pred_field_buf)¶ Takes the predicates used in the pddl action, compares them with the predicates, the section is already filled with, and completes the missing. some predicates with the same name can be found more than on time, if these two predicates use values of different types.
Parameters: - pddl_action – A PddlActionRepresentation, to filter predicates from.
- pred_field_buf – The Predicates gui text view buffer.
Returns: void
-
_PddlActionTabController__requirements_auto_complete
(raw_action, requ_dict)¶ Requirements auto complete, will set requirements as specified in pddl 2.1 paper.
Parameters: - raw_action – The pddl action string.
- req_dict – A dictionary, containing the requirements checkboxes and names as keys.
Returns: void
-
_PddlActionTabController__types_auto_complete
(pddl_action, types_buffer)¶ Takes the types from a pddl action, compares it with the types, already filled in to the type section and adds missing types.
Parameters: - types_buffer – The buffer of the types text view.
- pddl_action – A PddlActionRepresentation.
Returns: void
Registeres an auto apply button as subscriber to auto apply toggles.
Parameters: button – The Checkbox to add. Returns: void
-
auto_apply_enabled
= True¶
-
auto_apply_semaphore
= 0¶
-
auto_apply_toogled
(checkbox)[source]¶ Enables and disables the auto apply checkboxes in all action tabs of all states.
Parameters: checkbox – the caller checkbox, containing the up to date state of auto apply. Returns: void
-
auto_complete
(button, pred_buf, types_buf, requ_dict, pddl_action)[source]¶ tries to auto complete the predicates, types and Requirements fields, sets and saves them.
Parameters: - button – Unused.
- pred_buf – The text buffer of the predicates field.
- types_buf – The text buffer of the types field.
- requ_dict – A dictionary, containing the requirements checkboxes and names as keys.
- pddl_action – A PddlActionRepresentation, of the current Action in the Tab.
Returns: void
-
on_apply_changes
(button, desc_buf, action_buf, pred_buf, types_buf, req_dict)[source]¶ Saves all changes to the rafcon semantic tab.
Parameters: - button – Unused.
- desc_buf – The buffer of the description text view.
- action_buf – The buffer of the pddl action text view.
- pred_buf – The buffer of the predicates text view.
- types_buf – The buffer of the types text view.
- req_dict – A dictionary, containing the requirements checkboxes and their names as keys.
Returns: void
Removes an auto apply button from the subscriber list.
Parameters: button – The Checkbox to remove. Returns: void
-
save_data
(buffer, key, saved_manually)[source]¶ Reads the values of the tab elements and saves them under the specified key in the semantic section, saves only if saved_manually or auto_save_enabled is true.
Parameters: - buffer – A buffer contining the values to store.
- key – A key of the semantic dict in the requirements section.
- saved_manually – True if saved manually, false otherwhise.
Returns: void
-
save_requirements
(checkbox, req_dict, saved_manually)[source]¶ Saves all requirements specified in the gui, saves only if saved_manually or auto_save_enabled is true.
Parameters: - checkbox – Unused
- req_dict – A dictionary, containing the requirements checkboxes and names as keys.
- saved_manually – True if saved manually, false otherwhise.
Returns: void
-
2.4. rafcontpp.control.planning_controller module¶
-
class
rafcontpp.control.planning_controller.
PlanningController
(datastore)[source]¶ Bases:
object
PlanningController handles everything about the topic planning. it loads built-in scripts as well, als importing custom planner integrations. It also starts the planning process, and feeds the datastore with the plan, given by the planner.
Parameters: datastore – A datastore, containing all necessary data. -
_PlanningController__discover_class
(script)¶ Discover_class receives a script like “planner_script”, it imports it and discovers the class, which implements the plan_scenario method.
Parameters: script – The name of a custom planner integration module. Returns: A (script_name, class_name) tuple.
-
_PlanningController__get_built_in_script
(shortcut)¶ This function tries to resolve a given shortcut e.g. the name of a built in planner in the list.
Parameters: shortcut – Some string, hopefully a shortcut. Returns: (script_name,script_path) tuple, or None if the shortcut was not found in the list.
-
_PlanningController__plan_and_report
(callback_function, planner)¶ Plan and report triggers the planner, and evaluates the planning report e.g. storing the plan in the datastore. Due planning could take a long time this method should be called async.
Parameters: - current_thread – The Interruptable Thread, this function runs in (automatically added by the thread.).
- callback_function – A call back function called after planning.
- planner – The planner to plan with.
Returns: void
-
_PlanningController__split_and_add_to_path
(script_path)¶ Splits the script path into the directory path, and the script name, adds the directory Path to PYTHONPATH and returns the scripname.
Parameters: script_path – The path of a custom planner script like /home/planner_script.py. Returns: String: The Name of the script e.g. planner_script
-
execute_planning
(callback_func)[source]¶ Execute_planning loads built-in scripts, imports custom scripts, and executes them. it starts the planner in a new thread, and calls the callback_function when finish.
Parameters: callback_func – Is callback_func(Boolean):void planning will be executed async, and call this function when finish. Returns: InterruptableThread: The planning thread
-
2.5. rafcontpp.control.planning_setup_form_controller module¶
-
class
rafcontpp.control.planning_setup_form_controller.
PlanningSetupFormController
(datastore)[source]¶ Bases:
object
This is the controller of the Planning Setup Form.
Parameters: datastore – A Datastore -
_PlanningSetupFormController__get_current_selected_state_if_valid
()¶ Takes and validates the current selected state. Returns None if no, multiple or no valid state is selected.
Returns: HierarchyState: A valid root state or None
-
_PlanningSetupFormController__prepare_datastore
(datastore_to_prepare, state_pool_string, type_db_path, planner_text, planner_script_path, planner_argv_text, facts_path, generate_into_state, sm_name, sm_save_dir, keep_related_files, file_save_dir, rt_data_path, as_reference)¶ __prepare_datastore saves the given data into the datastore, and checks if data is missing.
Parameters: - setup_form – The setup form, to be able to destroy it.
- state_pool_string – The statepool paths as colon seperated string.
- type_db_path – The path of the type db file as string.
- planner_text – The text of the planner field e.g. Other… or Fast-Downward Planning System.
- planner_script_path – The path of a planner script, or an empty String if there is none.
- planner_argv_text – An argv vector for the planner.
- facts_path – The Path of the facts file as String.
- sm_name – The desired name of the State machine.
- sm_save_dir – The path where to save the State machine as string.
- keep_related_files – True if related files should be keept, Fals if they should be deleted.
- file_save_dir – The path where to save related files, or an empty string if files shouldn’t be keept.
- rt_data_path – The path where to find the runtime data file. Or an empty string if there is no runtime data.
- as_reference – True if the runtime data path should be used as reference, False if it should directly be copied into the State. if rt_data_path is empty, this field is irrelevant.
Returns: void
-
_PlanningSetupFormController__string_to_string_array
(string)¶ A little method, that splits a colon seperated string into a string array.
Parameters: string – A string, containing colon seperated substrings. Returns: A list of substrings e.g. a:b:c –> [a,b,c]
-
_PlanningSetupFormController__wait_and_hide
(thread, planning_wait_window)¶ wait and hide should be executed in another thread, it joins the planning thread, closes the wait window and decrements the planning button.
Parameters: - thread – The thread to wait for
- planning_wait_window – A window to hide and destroy, when the thread to wait for terminated.
Returns: void
-
on_apply
(button, setup_form, state_pool_string, type_db_path, planner_text, planner_script_path, planner_argv_text, facts_path, generate_into_state, sm_name, sm_save_dir, keep_related_files, file_save_dir, rt_data_path, as_reference)[source]¶ on_apply filles the datastore with new data entered into the setup form, saves it in the configuration, destroys the setup form, triggeres the pipeline e.g. the execution controller, and increments the plan task button, to indicate a running task.
Parameters: - button – Unused.
- setup_form – The setup form, to be able to destroy it.
- state_pool_string – The statepool paths as colon seperated string.
- type_db_path – The path of the type db file as string.
- planner_text – The text of the planner field e.g. Other… or Fast-Downward Planning System.
- planner_script_path – The path of a planner script, or an empty String if there is none.
- planner_argv_text – An argv vector for the planner.
- facts_path – The Path of the facts file as String.
- sm_name – The desired name of the State machine.
- sm_save_dir – The path where to save the State machine as string.
- keep_related_files – True if related files should be keept, Fals if they should be deleted.
- file_save_dir – The path where to save related files, or an empty string if files shouldn’t be keept.
- rt_data_path – The path where to find the runtime data file. Or an empty string if there is no runtime data.
- as_reference – True if the runtime data path should be used as reference, False if it should directly be copied into the State. if rt_data_path is empty, this field is irrelevant.
Returns: void
-
on_choose_runtime_data
(chooser, runtime_data_entry)[source]¶ Receivs a file chooser and a text entry, reads the filepath of the chooser and sets it as text into the entry.
Parameters: - chooser – A GtkFileChooserButton
- runtime_data_entry – A GtkEntry
Returns: void
-
on_choose_state_pool
(chooser, chooser_entry)[source]¶ Receives a directory chooser and a text entry, reads the path, set in the chooser and appends it to the text of the text entry.
Parameters: - chooser – A GtkFileChooserButton
- chooser_entry – A GtkEntry
Returns: void
-
on_destroy
(button, setup_form, state_pool_string, type_db_path, planner_text, planner_script_path, planner_argv_text, facts_path, generate_into_state, sm_name, sm_save_dir, keep_related_files, file_save_dir, rt_data_path, as_reference)[source]¶ on_destroy destroys the setup form, but saves the current configuration into a file.
Parameters: - button – Unused.
- setup_form – The setup form, to be able to destroy it.
- state_pool_string – The statepool paths as colon seperated string.
- type_db_path – The path of the type db file as string.
- planner_text – The text of the planner field e.g. Other… or Fast-Downward Planning System.
- planner_script_path – The path of a planner script, or an empty String if there is none.
- planner_argv_text – An argv vector for the planner.
- facts_path – The Path of the facts file as String.
- sm_name – The desired name of the State machine.
- sm_save_dir – The path where to save the State machine as string.
- keep_related_files – True if related files should be keept, Fals if they should be deleted.
- file_save_dir – The path where to save related files, or an empty string if files shouldn’t be keept.
- rt_data_path – The path where to find the runtime data file. Or an empty string if there is no runtime data.
- as_reference – True if the runtime data path should be used as reference, False if it should directly be copied into the State. if rt_data_path is empty, this field is irrelevant.
Returns: void
-
on_show_state_pool_info
(button, setup_form, state_pool_string, type_db_path, planner_text, planner_script_path, planner_argv_text, facts_path, generate_into_state, sm_name, sm_save_dir, keep_related_files, file_save_dir, rt_data_path, as_reference)[source]¶ - Show state pool info, uses the provided state pools and the type file to collect details, and show them in a state pool info window.
Parameters: - button – Unused.
- setup_form – The setup form, to be able to set it as parent.
- state_pool_string – The statepool paths as colon seperated string.
- type_db_path – The path of the type db file as string.
- planner_text – The text of the planner field e.g. Other… or Fast-Downward Planning System.
- planner_script_path – The path of a planner script, or an empty String if there is none.
- planner_argv_text – An argv vector for the planner.
- facts_path – The Path of the facts file as String.
- sm_name – The desired name of the State machine.
- sm_save_dir – The path where to save the State machine as string.
- keep_related_files – True if related files should be keept, Fals if they should be deleted.
- file_save_dir – The path where to save related files, or an empty string if files shouldn’t be keept.
- rt_data_path – The path where to find the runtime data file. Or an empty string if there is no runtime data.
- as_reference – True if the runtime data path should be used as reference, False if it should directly be copied into the State. if rt_data_path is empty, this field is irrelevant.
Returns: void
-