robokudo.utils.module_loader ============================ .. py:module:: robokudo.utils.module_loader .. autoapi-nested-parse:: Dynamic module loading utilities for Robokudo. This module provides functionality for dynamically loading Robokudo modules and components. It supports loading: * Analysis engines * Annotators * Camera configurations * Action servers * IO modules * Semantic maps * Object knowledge bases * Tree components * Types and utilities The module handles: * ROS package path resolution * Module type management * Dynamic module importing * File path resolution Classes ------- .. autoapisummary:: robokudo.utils.module_loader.RobokudoModuleType robokudo.utils.module_loader.ModuleLoader Module Contents --------------- .. py:class:: RobokudoModuleType Bases: :py:obj:`enum.Enum` Enumeration of Robokudo module types. Defines the standard module types and their paths within a ROS package. .. py:attribute:: ActionServer :value: ['action_servers'] Action server modules .. py:attribute:: Annotator :value: ['annotators'] Annotator modules .. py:attribute:: AnalysisEngine :value: ['descriptors', 'analysis_engines'] Analysis engine descriptors .. py:attribute:: CameraConfig :value: ['descriptors', 'camera_configs'] Camera configuration descriptors .. py:attribute:: IO :value: ['io'] Input/output modules .. py:attribute:: SemanticMap :value: ['descriptors', 'semantic_maps'] Semantic map modules .. py:attribute:: ObjectKnowledgeBase :value: ['descriptors', 'object_knowledge'] Object knowledge base modules .. py:attribute:: TreeComponents :value: ['tree_components'] Behavior tree components .. py:attribute:: Types :value: ['types'] Type modules .. py:attribute:: Utils :value: ['utils'] Utility modules .. py:attribute:: Data :value: ['data'] Data modules .. py:class:: ModuleLoader Dynamic module loader for Robokudo components. Handles loading of various Robokudo module types from ROS packages. Provides path resolution and module importing functionality. .. py:attribute:: logger :value: None The logger for the module loader instance. .. py:method:: _load_module(ros_pkg_name: str, module_type: RobokudoModuleType, module_name: str) -> types.ModuleType Dynamically import a submodule of the 'robokudo' package (or another package). E.g., 'robokudo.descriptors.analysis_engines.demo' :param ros_pkg_name: Name of ROS package :param module_type: Type of module to load :param module_name: Name of module to load :return: Loaded module object .. py:method:: load_ae(ros_pkg_name: str, module_name: str) -> robokudo.analysis_engine.AnalysisEngineInterface Load an Analysis Engine (AE). Expects a class `AnalysisEngine` in the loaded module. The ROS package must be in the same workspace with path structure: ``$package_path/src/robokudo_example_package/descriptors/analysis_engines/`` :param ros_pkg_name: Name of ROS package containing AE :param module_name: Name of analysis engine module :return: Root of loaded analysis engine .. py:method:: load_annotator(ros_pkg_name: str, module_name: str) -> types.ModuleType Load an annotator module. You can adjust the returned object as needed. :param ros_pkg_name: Name of ROS package containing annotator :param module_name: Name of annotator module :return: None (TODO: implement annotator loading) :rtype: None .. py:method:: load_camera_config(ros_pkg_name: str, module_name: str) -> typing_extensions.Any Load a camera config module. Expects class `CameraConfig`. :param ros_pkg_name: Name of ROS package containing config :param module_name: Name of camera config module :return: Loaded camera configuration .. py:method:: load_io(ros_pkg_name: str, module_name: str) -> types.ModuleType Load an I/O module. Customize this if there's a specific class to instantiate. :param ros_pkg_name: Name of ROS package containing IO module :param module_name: Name of IO module :return: Loaded IO module .. py:method:: load_object_knowledge_base(ros_pkg_name: str, module_name: str) -> robokudo.object_knowledge_base.BaseObjectKnowledgeBase Load an ObjectKnowledgeBase given the module name and the ros package name. The path to the AE within the package is meant to be: $package_path/src/PACKAGE_NAME/descriptors/object_knowledge/. :param ros_pkg_name: Name of ROS package containing knowledge base :param module_name: Name of knowledge base module :return: Loaded object knowledge base .. py:method:: load_semantic_map(ros_pkg_name: str, module_name: str, _skip_ros: bool = False) -> robokudo.semantic_map.BaseSemanticMap Load a semantic map module. Expects class `SemanticMap`. :param ros_pkg_name: Name of ROS package containing semantic map :param module_name: Name of semantic map module :param _skip_ros: Skip ROS-related initialization in SemanticMap constructor :type _skip_ros: bool :return: Loaded semantic map .. py:method:: load_tree_components(ros_pkg_name: str, module_name: str) -> types.ModuleType Load tree components. If there's a main class, instantiate it here. :param ros_pkg_name: Name of ROS package containing components :param module_name: Name of tree components module :return: Loaded tree components module .. py:method:: load_types(ros_pkg_name: str, module_name: str) -> types.ModuleType Load a 'types' module, or a class if needed. :param ros_pkg_name: Name of ROS package containing types :param module_name: Name of types module :return: Loaded types module .. py:method:: load_utils(ros_pkg_name: str, module_name: str) -> types.ModuleType Load a 'utils' module, or a class if needed. :param ros_pkg_name: Name of ROS package containing utilities :param module_name: Name of utility module :return: Loaded utility module .. py:method:: get_file_paths(ros_pkg_name: str, module_type: RobokudoModuleType, dir_name: str, file_extension: str = None) -> typing_extensions.List[str] Get paths to files in module directory. If you previously used this to read data files from the 'source' folder, you can either remove it or refactor to read from: 1) get_package_share_directory('robokudo'), or 2) standard Python package resources. If you truly need to load data from the installed package, see: - `ament_index_python` (to find share dir) - or `importlib.resources` For now, you might remove this method or keep it if you adapt the logic. :param ros_pkg_name: Name of ROS package :param module_type: Type of module to search :param dir_name: Name of directory to search :param file_extension: Optional file extension filter :return: List of paths to matching files