Major refactoring to improve code quality, maintainability, and API organization for publication-quality research software. Phase 1 - Code Quality Foundation: - Add comprehensive type hints across all core modules (500+ annotations) - Create custom exception hierarchy with 20+ specialized exceptions - Replace all print() statements with proper logging (debug, info, warning, error, critical) - Enhance all docstrings with Args/Returns/Raises sections - Improve error handling with exception chaining Modified core modules: - rsi_client.py: State machine with typed exceptions, full type hints - network_handler.py: CSV logging and UDP communication with typed interfaces - config_parser.py: XML parsing with proper exception handling - safety_manager.py: Safety validation with typed limits - __init__.py: Clean exports for all public APIs Phase 5 - Namespaced API Architecture: - Restructure RSIAPI as orchestrator providing 9 specialized namespaces - Create clean separation of concerns with dedicated API classes New namespace APIs: - motion_api.py: Motion control (Cartesian, joints, trajectories) - io_api.py: Digital I/O control - krl_api.py: KRL program manipulation utilities - safety_api.py: Safety management and limits - monitoring_api.py: Live data access and monitoring - logging_api.py: CSV data logging - diagnostics_api.py: Network diagnostics (Phase 2 placeholder) - viz_api.py: Static and live visualization - tools_api.py: Utilities, debugging, inspection Breaking Changes: - No backward compatibility - clean slate API design - Old: api.start_rsi() → New: api.start() - Old: api.update_cartesian(...) → New: api.motion.update_cartesian(...) - See migration guide in PHASE_5_SUMMARY.md Benefits: - Organized and discoverable API structure - Scalable architecture for future enhancements - Type-safe with full IDE autocomplete support - Easier testing and maintenance - Professional industry-standard design pattern Files changed: 6 modified, 9 new (net -37 lines, improved organization)
106 lines
2.3 KiB
Python
106 lines
2.3 KiB
Python
"""
|
|
RSIPI - Robot Sensor Interface Python Integration
|
|
|
|
A lightweight Python library for real-time control of KUKA industrial robots
|
|
via the RSI 3.3 protocol. Provides high-level namespaced API for motion control,
|
|
I/O, logging, visualization, and KRL program manipulation.
|
|
|
|
Example:
|
|
>>> from RSIPI import RSIAPI
|
|
>>> api = RSIAPI('RSI_EthernetConfig.xml')
|
|
>>> api.start()
|
|
>>> api.motion.update_cartesian(X=10, Y=5, Z=0)
|
|
>>> api.stop()
|
|
"""
|
|
|
|
__version__ = "2.0.0"
|
|
__author__ = "RSIPI Development Team"
|
|
|
|
# Main API
|
|
from .rsi_api import RSIAPI
|
|
|
|
# Namespace APIs (for type hints and advanced use)
|
|
from .motion_api import MotionAPI
|
|
from .io_api import IOAPI
|
|
from .krl_api import KRLAPI
|
|
from .safety_api import SafetyAPI
|
|
from .monitoring_api import MonitoringAPI
|
|
from .logging_api import LoggingAPI
|
|
from .diagnostics_api import DiagnosticsAPI
|
|
from .viz_api import VizAPI
|
|
from .tools_api import ToolsAPI
|
|
|
|
# Core client (for advanced use)
|
|
from .rsi_client import RSIClient, ClientState
|
|
|
|
# Exceptions
|
|
from .exceptions import (
|
|
RSIError,
|
|
RSINetworkError,
|
|
RSIConnectionError,
|
|
RSITimeoutError,
|
|
RSIPacketError,
|
|
RSISafetyError,
|
|
RSISafetyViolation,
|
|
RSIEmergencyStop,
|
|
RSILimitExceeded,
|
|
RSIConfigError,
|
|
RSIConfigParseError,
|
|
RSIMissingConfigError,
|
|
RSIStateError,
|
|
RSIInvalidTransition,
|
|
RSIClientNotReady,
|
|
RSIDataError,
|
|
RSILoggingError,
|
|
RSIVariableError,
|
|
RSIMotionError,
|
|
RSITrajectoryError,
|
|
RSIKinematicsError,
|
|
)
|
|
|
|
__all__ = [
|
|
# Main API (primary entry point)
|
|
"RSIAPI",
|
|
|
|
# Namespace APIs
|
|
"MotionAPI",
|
|
"IOAPI",
|
|
"KRLAPI",
|
|
"SafetyAPI",
|
|
"MonitoringAPI",
|
|
"LoggingAPI",
|
|
"DiagnosticsAPI",
|
|
"VizAPI",
|
|
"ToolsAPI",
|
|
|
|
# Core
|
|
"RSIClient",
|
|
"ClientState",
|
|
|
|
# Exceptions
|
|
"RSIError",
|
|
"RSINetworkError",
|
|
"RSIConnectionError",
|
|
"RSITimeoutError",
|
|
"RSIPacketError",
|
|
"RSISafetyError",
|
|
"RSISafetyViolation",
|
|
"RSIEmergencyStop",
|
|
"RSILimitExceeded",
|
|
"RSIConfigError",
|
|
"RSIConfigParseError",
|
|
"RSIMissingConfigError",
|
|
"RSIStateError",
|
|
"RSIInvalidTransition",
|
|
"RSIClientNotReady",
|
|
"RSIDataError",
|
|
"RSILoggingError",
|
|
"RSIVariableError",
|
|
"RSIMotionError",
|
|
"RSITrajectoryError",
|
|
"RSIKinematicsError",
|
|
|
|
# Version
|
|
"__version__",
|
|
]
|