Code Organization Update - Motion vs Communication Separation
Date: 2025-09-12
Decision: Maintain separate codebases for movement and communication during development
Current Architecture
Movement Code:
- Location:
/code/Arduino/TentacleMovement/ - Status: Mature algorithms (SearchingV31, Hysteresis implementations)
- Focus: Servo control, behavioral patterns, spatial memory
Communication Code:
- Location:
/code/Arduino/Lighting/(optical communication components) - Status: Newly developed, protocol validation phase
- Focus: Signal processing, photodiode detection, LED modulation
Rationale for Separation
Development Benefits:
- Independent testing: Movement algorithms can be validated without communication functionality
- Debugging isolation: Signal processing issues vs mechanical control issues require different approaches
- Different maturity levels: Movement code is stable, communication code is experimental
- Resource requirements: Communication requires dual ADC channels, movement needs servo PWM
Technical Benefits:
- Modular architecture: Clean interfaces enable easier integration later
- Code reusability: Communication modules can be shared between units
- Platform flexibility: Movement and communication may have different hardware requirements
- Parallel development: Different aspects can be developed simultaneously
Integration Planning
Phase 1 (Current):
- Movement: Autonomous exploration patterns
- Communication: Optical protocol development and directional sensing
Phase 2 (Near term):
- Combined attention-seeking behavior: Movement guided by directional photodiode signals
- Communication-triggered movement: Units approach each other for signal transmission
Phase 3 (Integration):
- Unified behavioral system: Movement patterns influenced by communication events
- Shared memory updates affecting both movement and communication decisions
- Multi-unit coordination through optical protocols
Directory Structure Recommendation
/code/Arduino/
├── TentacleMovement/ # Servo control, behavioral algorithms
│ ├── SearchingV31.ino
│ └── Hysteresis_patterns/
├── OpticalCommunication/ # NEW: Signal processing, protocols
│ ├── OpticalCommsTesterTX.ino
│ ├── OpticalCommsTesterRX.ino
│ └── DirectionalSensing.ino
├── Integration/ # NEW: Combined behaviors
│ └── HysteresisUnified.ino (future)
└── Utilities/ # Shared functions, hardware abstraction
Interface Design
Movement → Communication:
bool needsAttention()- movement algorithm requests communicationfloat getSearchDirection()- current exploration vectorvoid pauseForCommunication()- halt movement during signal transmission
Communication → Movement:
float getSignalDirection()- directional photodiode bearingbool signalDetected()- attention signal presentvoid completedCommunication()- resume movement patterns
Shared State:
- Spatial memory grid (updated by both subsystems)
- Energy level (affected by communication events)
- Unit position and orientation
Development Approach
Immediate (September 2025):
- Complete dual photodiode directional sensing in separate codebase
- Validate communication protocols independently
- Define interface specifications for eventual integration
Integration Phase (October 2025):
- Create unified codebase incorporating both subsystems
- Test combined attention-seeking + communication behaviors
- Optimize resource usage for dual-core RP2040 architecture
Production (November 2025):
- Single unified codebase per unit
- Optimized for hardware constraints and performance requirements
- Full multi-unit coordination capabilities
Decision: Maintain separation until integration phase for development efficiency and code quality. Clean interfaces between subsystems will facilitate eventual merger while preserving the ability to develop and test each component independently.