pycram.cache_manager#

Classes#

CacheManager

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

Module Contents#

class pycram.cache_manager.CacheManager(cache_dir: str, data_directory: typing_extensions.List[str], clear_cache: bool = True)#

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

cache_cleared: bool = False#

Indicate whether the cache directory has been cleared at least once since beginning or not.

cache_dir#
data_directories#
clear_cache()#

Clear the cache directory.

delete_cache_dir()#

Delete the cache directory.

update_cache_dir_with_object(path: str, ignore_cached_files: bool, object_description: pycram.description.ObjectDescription, object_name: str, scale_mesh: typing_extensions.Optional[float] = None, mesh_transform: typing_extensions.Optional[pycram.datastructures.pose.TransformStamped] = None, color: typing_extensions.Optional[pycram.datastructures.dataclasses.Color] = None) str#

Check if the file is already in the cache directory, if not preprocess and save 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.

  • scale_mesh – The scale of the mesh.

  • mesh_transform – The transformation matrix to apply to the mesh.

  • color – The color of the object.

Returns:

The path of the cached file.

look_for_file_in_data_dir(path_object: pathlib.Path) str#
Look for a file in the data directory of the World. If the file is not found in the data directory, raise a

FileNotFoundError.

Parameters:

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

create_cache_dir_if_not_exists()#

Create the cache directory if it does not exist.

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

Check 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#

Check 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#

Check if the file in the given path exists in the cache directory the given file extension. Instead, replace the given extension with the extension of the used ObjectDescription and check for that one.

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

  • object_description – The object description of the file.