robokudo.utils.module_loader¶
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
World descriptors
Tree components
Types and utilities
The module handles:
ROS package path resolution
Module type management
Dynamic module importing
File path resolution
Classes¶
Enumeration of Robokudo module types. |
|
Dynamic module loader for Robokudo components. |
Module Contents¶
- class robokudo.utils.module_loader.RobokudoModuleType¶
-
Bases:
enum.EnumEnumeration of Robokudo module types.
Defines the standard module types and their paths within a ROS package.
- Annotator = ['annotators']¶
-
Annotator modules
- AnalysisEngine = ['descriptors', 'analysis_engines']¶
-
Analysis engine descriptors
- CameraConfig = ['descriptors', 'camera_configs']¶
-
Camera configuration descriptors
- IO = ['io']¶
-
Input/output modules
- WorldDescriptor = ['descriptors', 'worlds']¶
-
World descriptor modules
- TreeComponents = ['tree_components']¶
-
Behavior tree components
- Types = ['types']¶
-
Type modules
- Utils = ['utils']¶
-
Utility modules
- Data = ['data']¶
-
Data modules
- class robokudo.utils.module_loader.ModuleLoader¶
-
Dynamic module loader for Robokudo components.
Handles loading of various Robokudo module types from ROS packages. Provides path resolution and module importing functionality.
- logger = None¶
-
The logger for the module loader instance.
- _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’
- Parameters:
-
ros_pkg_name – Name of ROS package
module_type – Type of module to load
module_name – Name of module to load
- Returns:
-
Loaded module object
- 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/- Parameters:
-
ros_pkg_name – Name of ROS package containing AE
module_name – Name of analysis engine module
- Returns:
-
Root of loaded analysis engine
- load_annotator(ros_pkg_name: str, module_name: str) types.ModuleType¶
-
Load an annotator module. You can adjust the returned object as needed.
- Parameters:
-
ros_pkg_name – Name of ROS package containing annotator
module_name – Name of annotator module
- Returns:
-
The requested module. This is not pointing to an Annotator in this module. It’s just the module.
- Return type:
-
module
- load_camera_config(ros_pkg_name: str, module_name: str) typing_extensions.Any¶
-
Load a camera config module. Expects class CameraConfig.
- Parameters:
-
ros_pkg_name – Name of ROS package containing config
module_name – Name of camera config module
- Returns:
-
Loaded camera configuration
- 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.
- Parameters:
-
ros_pkg_name – Name of ROS package containing IO module
module_name – Name of IO module
- Returns:
-
Loaded IO module
- load_world_descriptor(ros_pkg_name: str, module_name: str) robokudo.world_descriptor.BaseWorldDescriptor¶
-
Load a WorldDescriptor given the module name and the ros package name.
The path within the package is meant to be: $package_path/src/PACKAGE_NAME/descriptors/worlds/.
- Parameters:
-
ros_pkg_name – Name of ROS package containing world descriptor
module_name – Name of world descriptor module
- Returns:
-
Loaded world descriptor
- load_tree_components(ros_pkg_name: str, module_name: str) types.ModuleType¶
-
Load tree components. If there’s a main class, instantiate it here.
- Parameters:
-
ros_pkg_name – Name of ROS package containing components
module_name – Name of tree components module
- Returns:
-
Loaded tree components module
- load_types(ros_pkg_name: str, module_name: str) types.ModuleType¶
-
Load a ‘types’ module, or a class if needed.
- Parameters:
-
ros_pkg_name – Name of ROS package containing types
module_name – Name of types module
- Returns:
-
Loaded types module
- load_utils(ros_pkg_name: str, module_name: str) types.ModuleType¶
-
Load a ‘utils’ module, or a class if needed.
- Parameters:
-
ros_pkg_name – Name of ROS package containing utilities
module_name – Name of utility module
- Returns:
-
Loaded utility module
- get_file_paths(ros_pkg_name: str, module_type: RobokudoModuleType, dir_name: str, file_extension: typing_extensions.Optional[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:
get_package_share_directory(‘robokudo’), or
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.
- Parameters:
-
ros_pkg_name – Name of ROS package
module_type – Type of module to search
dir_name – Name of directory to search
file_extension – Optional file extension filter
- Returns:
-
List of paths to matching files
- static get_module_path(module_name: str) pathlib.Path¶