robokudo.utils.file_loader ========================== .. py:module:: robokudo.utils.file_loader .. autoapi-nested-parse:: File path resolution utilities for RoboKudo. This module provides utilities for resolving file paths in ROS packages. :module: file_loader :synopsis: File path resolution utilities for ROS packages :moduleauthor: RoboKudo Team :Dependencies: * pathlib * rospkg * logging Classes ------- .. autoapisummary:: robokudo.utils.file_loader.FileLoader Module Contents --------------- .. py:class:: FileLoader File path resolution helper for ROS packages. This class provides methods for resolving file paths in ROS packages. :Example: .. code-block:: python pkg_path = FileLoader.get_ros_pkg_path('my_package') file_path = FileLoader.get_path_to_file_in_ros_package('my_package', 'config/params.yaml') .. py:method:: get_ros_pkg_path(ros_pkg_name: str) -> pathlib.Path :staticmethod: Get a Path object to a ROS2 package given the name Throws OSError if ROS2 package can't be found. :param ros_pkg_name: name of a ros2 package :return: path object with the ros2 package path :raises OSError: If ROS package cannot be found :Example: .. code-block:: python pkg_path = loader.get_ros_pkg_path('my_package') assert pkg_path.exists() .. py:method:: get_path_to_file_in_ros_package(ros_pkg_name: str, relative_path: str) -> pathlib.Path :staticmethod: Get a Path object to a given the filename inside a ROS package. Please note, that relative_path should NOT start with '/', because then it would be considered as an absolute path from pathlib.Path.joinpath() Throws OSError if ROS package can't be found or relative_path in ROS package doesn't exist. :param ros_pkg_name: name of a ros package :param relative_path: the filename of the desired file, relative to the path of ros_pkg_name :return: path object to the desired file relative the ros package :raises OSError: If package or file cannot be found :Example: .. code-block:: python file_path = loader.get_path_to_file_in_ros_package('my_package', 'config/params.yaml') assert file_path.exists() .. note:: The relative_path should NOT start with '/' to avoid being treated as an absolute path by pathlib.Path.joinpath()