Commit Graph

3 Commits

Author SHA1 Message Date
098f53aed2 Fix send/receive variable inversion and network loop performance
The variable naming follows KUKA convention (robot's perspective) where
send_variables = what the robot sends us (RIst, RSol) and
receive_variables = what the robot receives from us (RKorr, DiO).
All APIs were using them backwards — writing corrections to
send_variables and building response XML from them, meaning the robot
never received actual corrections.

- network_handler: parse incoming XML into send_variables, build
  response XML from receive_variables, use local dict snapshots
  to avoid per-key Manager IPC within the 4ms cycle
- motion_api: check receive_variables for RKorr/AKorr
- tools_api: write user corrections to receive_variables
- monitoring_api: read robot state from send_variables
- io_api: read digital inputs from send_variables
- krl_api: read Tech.T params from send_variables
- rsi_cli/rsi_graphing: add --config arg, remove hardcoded paths
- main.py: test runner with all examples and multiprocessing guard
2026-04-17 18:54:10 +01:00
0d70b71bc8 Phase 4: Advanced Motion Control - Complete Implementation
Implements professional-grade trajectory planning and execution capabilities
for industrial robotics applications. Adds velocity profiling, geometric
motion primitives, path blending, and coordinate frame transformations.

Features Added:
- Velocity profiling (trapezoidal and S-curve profiles)
- Geometric motion primitives (arc, circle, spiral)
- Path blending with cubic Hermite spline interpolation
- Coordinate transformations (BASE/WORLD/TOOL/WORK frames)

New API Methods (MotionAPI):
- generate_velocity_profile(trajectory, max_velocity, max_acceleration, profile)
- generate_arc(center, radius, start_angle, end_angle, steps, plane)
- generate_circle(center, radius, steps, plane)
- generate_spiral(center, start_radius, end_radius, pitch, revolutions, steps, plane, axis)
- blend_trajectories(traj1, traj2, blend_radius, blend_steps)
- transform_coordinates(pose, from_frame, to_frame, frame_offset)

Helper Functions:
- _calculate_distance() - Euclidean distance between waypoints
- _trapezoidal_profile() - Bang-bang velocity control
- _s_curve_profile() - Jerk-limited smooth profiles
- _find_blend_point() - Locate blend zone boundaries
- _cubic_blend() - Cubic Hermite spline interpolation

Examples Created (examples/advanced_motion/):
- 01_velocity_profiles.py (234 lines) - Trapezoidal vs S-curve profiling
- 02_geometric_primitives.py (225 lines) - Arc, circle, spiral patterns
- 03_path_blending.py (253 lines) - Smooth trajectory transitions
- 04_coordinate_transforms.py (284 lines) - Frame transformations
- 05_combined_motion.py (336 lines) - Complete production application
- README.md (584 lines) - Comprehensive documentation

Documentation:
- PHASE_4_SUMMARY.md - Detailed implementation documentation
- Updated ROADMAP.md to mark Phase 4 complete
- Comprehensive API documentation in examples/advanced_motion/README.md

Files Modified:
- src/RSIPI/motion_api.py (~550 lines added)
- ROADMAP.md (updated Phase 4 status)

Files Created:
- PHASE_4_SUMMARY.md
- examples/advanced_motion/ (6 new files, 1,916 total lines)

Statistics:
- New API methods: 5 public methods + 4 helper functions
- Example code: ~1,332 lines
- Documentation: ~584 lines
- Total additions: ~2,466 lines

Production Applications:
- Drilling and milling (expanding/contracting spirals)
- Assembly (circular insertion, smooth approaches)
- Inspection (spiral scanning, circular features)
- Welding/coating (continuous beads, smooth transitions)
- Pick and place (optimized cycles, blended paths)

Phase 4 Status:  COMPLETE
Date: January 17, 2026
2026-01-17 01:38:48 +00:00
a131ba4df8 Implement Phase 1 & Phase 5: Code quality improvements and namespaced API architecture
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)
2026-01-16 23:49:45 +00:00