pycram.cache_manager

Module Contents

Classes

CacheManager

The CacheManager is responsible for caching object description files and managing the cache directory.

class pycram.cache_manager.CacheManager(cache_dir: str, data_directory: typing_extensions.List[str])

The CacheManager is responsible for caching object description files and managing the cache directory.

Initializes the CacheManager.

Parameters:
  • cache_dir – The directory where the cached files are stored.

  • data_directory – The directory where all resource files are stored.

mesh_extensions: typing_extensions.List[str] = ['.obj', '.stl']

The file extensions of mesh files.

update_cache_dir_with_object(path: str, ignore_cached_files: bool, object_description: pycram.description.ObjectDescription, object_name: str) str

Checks if the file is already in the cache directory, if not it will be preprocessed and saved in the cache.

Parameters:
  • path – The path of the file to preprocess and save in the cache directory.

  • ignore_cached_files – If True, the file will be preprocessed and saved in the cache directory even if it is already cached.

  • object_description – The object description of the file.

  • object_name – The name of the object.

generate_description_and_write_to_cache(path: str, name: str, extension: str, cache_path: str, object_description: pycram.description.ObjectDescription) None

Generates the description from the file at the given path and writes it to the cache directory.

Parameters:
  • path – The path of the file to preprocess.

  • name – The name of the object.

  • extension – The file extension of the file to preprocess.

  • cache_path – The path of the file in the cache directory.

  • object_description – The object description of the file.

static write_to_cache(description_string: str, cache_path: str) None

Writes the description string to the cache directory.

Parameters:
  • description_string – The description string to write to the cache directory.

  • cache_path – The path of the file in the cache directory.

look_for_file_in_data_dir(path_object: pathlib.Path) str

Looks for a file in the data directory of the World. If the file is not found in the data directory, this method raises a FileNotFoundError.

Parameters:

path_object – The pathlib object of the file to look for.

create_cache_dir_if_not_exists()

Creates the cache directory if it does not exist.

is_cached(path: str, object_description: pycram.description.ObjectDescription) bool

Checks if the file in the given path is already cached or if there is already a cached file with the given name, this is the case if a .stl, .obj file or a description from the parameter server is used.

Parameters:
  • path – The path of the file to check.

  • object_description – The object description of the file.

Returns:

True if there already exists a cached file, False in any other case.

check_with_extension(path: str) bool

Checks if the file in the given ath exists in the cache directory including file extension.

Parameters:

path – The path of the file to check.

check_without_extension(path: str, object_description: pycram.description.ObjectDescription) bool

Checks if the file in the given path exists in the cache directory without file extension, the extension is added after the file name manually in this case.

Parameters:
  • path – The path of the file to check.

  • object_description – The object description of the file.