pitasc.model_interface

Convenience tools for accessing and modifying pitasc models more easily.

Models can be imported or created via the SimpleInterface class. Complex model elements like dictionaries or lists are represented by the PitascModelElement class. Simple data like string, float or csv:* are represented by basic python types like str, float, or list.

Example

>>> from pitasc.model_interface import SimpleInterface
>>> model = SimpleInterface()
>>> model.import_ros_file("pitasc_common", "examples/rosless/simple_move_rosless.xml")
# lots of [ Info  ] prints
(True, "Successfully loaded '/path/to/pitasc_common/examples/rosless/simple_move_rosless.xml' in X.XXX sec")
>>> model.configuration.update_rate  # access primitive value
125.0
>>> model.configuration.update_rate = 250  # set primitive value
>>> model.apps[0]  # access list element
class pitasc.model_interface.SimpleInterface(model=None)

Simplifies adaptation of a pitasc model and getting/setting member values.

SimpleInterface acts as a wrapper around pitasc.model.Model.

Parameters:

model (Model, optional) – Model that shall be adapted. If None, a new model will be created internally.

_model

Model instance being manipulated.

Type:

Model

add_element(parameter_path: str, element_type_name: str) None
property apps

Represents the list of applications (application skills) of the project.

Type:

PitascModelElement

property configuration

Represents the configuration of the project.

Type:

PitascModelElement

property environment

Represents the environment of the project.

Type:

PitascModelElement

get_file_path() str
get_model_info(model_type_name: str) Dict[str, str]
get_models_of_type(prototype: str) List[str]
get_package() str
get_package_path() str
get_parameter_info(parameter_path: str) Dict[str, str]
get_relative_file_path() str
import_file(file_path: str) None

Load a pitasc XML file.

Parameters:

file_path (str) – Absolute or relative file path of the existing XML file.

import_ros_file(package: str, file_name: str) Tuple[bool, str]

Load a pitasc XML file.

Warning

Does not raise an exception on error.

Note

Alias for load_project.

Parameters:
  • package (str) – Package name in which the XML file exists.

  • file_name (str) – Relative file path of the existing XML file.

Returns:

success flag, response message

Return type:

tuple(bool, str)

inspect_model(model_type_name: str) PitascModelElement

Retrieves information about a model that is available as a prototype, e.g. those defined in pitasc_library.

Parameters:

model_type_name (str) – Model name that you want to retrieve information about.

Returns:

Representation of the (prototype) model.

Return type:

PitascModelElement

load_project(existing_package: str, existing_file_name: str) Tuple[bool, str]

Load an existing project (corresponding to an existing pitasc XML file).

Warning

Does not raise an exception on error.

Note

Alias for import_ros_file.

Parameters:
  • existing_package (str) – Package name in which the XML file exists.

  • existing_file_name (str) – File path of the existing XML file relative to existing_package.

Returns:

success flag, response message

Return type:

tuple(bool, str)

property model

Model instance being manipulated.

Type:

Model

property monitors

List of available monitor types.

Type:

list of str

move_element(parameter_path: str, index: int) None
project_from_existing(existing_package: str, existing_file_name: str, package: str = 'pitasc_common', file_name: str | None = None) Tuple[bool, str]

Create a new project based on an existing pitasc XML file.

The new project corresponds to a new pitasc XML file.

Warning

Does not raise an exception on error.

Parameters:
  • existing_package (str) – Package name in which the template XML file exists.

  • existing_file_name (str) – File path of the template XML file relative to existing_package.

  • package (str) – Package name in which the new project should be saved.

  • file_name (str) – File path of the new project XML file relative to package. If set to None, it will auto-generate the file name as “apps/%Y%m%d_%H%M%S.xml”.

Returns:

success flag, response message

Return type:

tuple(bool, str)

project_from_template(robot: str = 'ur', package: str = 'pitasc_common', file_name: str | None = None) Tuple[bool, str]

Creates a new project based on an empty template containing only a robot.

Currently, the only available template contains a UR robot. The new project corresponds to a new pitasc XML file.

Warning

Does not raise an exception on error.

Parameters:
  • robot (str, optional) – Robot type to use for the project. Possible values: “ur”.

  • package (str, optional) – Package name in which the new project should be saved.

  • file_name (str, optional) – File path of the new project XML file relative to the package. If set to None, it will auto-generate the file name as “apps/%Y%m%d_%H%M%S.xml”.

Returns:

success flag, response message

Return type:

tuple(bool, str)

remove_element(parameter_path: str) None
save() None

Saves the current project under the name / path given during project creation.

save_as(file_name: str, package_name: str | None = None) None

Saves the current project under a new file name (file_name), which is relative to the given package_name. If no package_name is given, file_name can be an absolute path or relative, which is interpret relative to the current working directory.

Parameters:
  • file_name (str) – File path relative to the package path, relative to the current working directory or absolute.

  • package_name (str, optional) – Package name under which the file will be saved.

property scripts

List of available script types.

Type:

list of str

set_parameter_value(parameter_path: str, value: bool | int | float | str) Tuple[str, str]
set_reference_of_element(parameter_path: str, reference: str) str
property skills

List of available skill types.

Type:

list of str