Extend AeroAlign with mixed CoG planning and telemetry base

This commit is contained in:
2026-03-11 23:14:33 +01:00
parent 538c3081bf
commit 56890272a0
28 changed files with 1631 additions and 1332 deletions
+48 -340
View File
@@ -1,360 +1,68 @@
# SkyLogic AeroAlign - Implementation Status
**Date**: 2026-01-22
**Phase**: 4 (Differential Measurement) - COMPLETE ✅
**Progress**: 32/130 tasks (25%)
**Date**: 2026-03-11
**State**: AeroAlign working, CoG integration base prepared
---
## Repository Status
## ✅ Completed Work
The project now has two layers:
### Phase 1: Setup (7/7 tasks - 100%)
1. working AeroAlign firmware and UI for IMU-based angle measurement
2. shared protocol and documentation base for the upcoming CoG scale extension
**Directory Structure Created**:
```
ewd-digiflo/
├── firmware/
│ ├── master/src/ ✅ Master firmware source
│ ├── master/data/ ✅ Web UI location
│ ├── slave/src/ ✅ Slave firmware source
├── hardware/
│ ├── cad/ ✅ 3D models (documentation)
│ ├── schematics/ ✅ Wiring diagrams + BOM
│ └── docs/ ✅ Hardware docs
├── docs/ ✅ End-user guides
└── specs/001-wireless-rc-telemetry/ ✅ Design docs
```
## Implemented
**Configuration Files**:
-`firmware/master/platformio.ini` - ESP32-C3/S3 build config
-`firmware/slave/platformio.ini` - Multi-slave variants (8 nodes)
-`firmware/master/src/config.h` - WiFi, GPIO, constants
-`firmware/slave/src/config.h` - Master MAC, node ID
### Firmware
---
- Master firmware builds for `esp32-c3` and `esp32-s3`
- IMU slave firmware builds for the current slave environments, including S3
- Master and Slave use the same direct MPU6050 register access approach
- shared ESP-NOW packet format supports device typing:
- `IMU`
- `CoG Scale`
- `Hybrid`
- Master data model and UI can already represent CoG-style telemetry fields
### Phase 2: Foundational (13/13 tasks - 100%)
### UI
#### Hardware Foundation
- current tabs remain angle-focused: `Sensors`, `Differential`, `System`
- mixed-device node cards are supported
- differential selection excludes CoG-only nodes
- Master battery display is hidden when the ADC path is not available
-**Bill of Materials** (`hardware/schematics/bom.csv`)
- Complete component list with Amazon ASINs
- Pricing: $72 for 2-sensor system, $289 for 8-sensor system
- Alternative components documented
### Documentation
- **Wiring Diagram** (`hardware/schematics/sensor_node_wiring.md`)
- Complete ESP32-MPU6050-LiPo-TP4056 wiring
- Battery monitoring circuit (voltage divider)
- Power supply design (HT7333 LDO)
- Assembly instructions and troubleshooting
- README rewritten for combined AeroAlign + CoG direction
- IMU wiring brought to current C3/S3 and battery-monitoring behavior
- new CoG wiring guide added
- BOM converted from placeholder marketplace list to current component overview
- CAD readme updated to include planned CoG fixtures
-**3D CAD Documentation** (`hardware/cad/README.md`)
- Sensor housing specs (38mm × 28mm × 18mm)
- Control surface clips (3mm, 5mm, 8mm)
- Print settings for PLA/PETG
- Multi-sensor expansion mounts (Phase 8 ready)
## Current Hardware Documentation
#### Firmware Foundation - Master Node
- [README.md](/Users/florianklaner/Github/AeroAlign/README.md)
- [sensor_node_wiring.md](/Users/florianklaner/Github/AeroAlign/hardware/schematics/sensor_node_wiring.md)
- [cog_scale_wiring.md](/Users/florianklaner/Github/AeroAlign/hardware/schematics/cog_scale_wiring.md)
- [bom.csv](/Users/florianklaner/Github/AeroAlign/hardware/schematics/bom.csv)
- [hardware/cad/README.md](/Users/florianklaner/Github/AeroAlign/hardware/cad/README.md)
- [AEROALIGN_COG_INTEGRATION.md](/Users/florianklaner/Github/AeroAlign/docs/AEROALIGN_COG_INTEGRATION.md)
-**IMU Driver** (`firmware/master/src/imu_driver.cpp/h`)
- MPU6050 6-axis sensor support
- Complementary filter (α=0.98) for angle calculation
- ±0.5° accuracy (static measurement)
- Temperature monitoring
- Calibration support
## What Works Right Now
- **Calibration Manager** (`firmware/master/src/calibration.cpp/h`)
- NVS (Non-Volatile Storage) persistence
- Zero-point offset storage per node
- Temperature-tagged calibration
- Load/save/clear operations
- Master AP + web UI
- IMU node discovery over ESP-NOW
- calibration and differential measurement for angle nodes
- S3-safe IMU access path
- optional battery reporting on Master hardware where ADC is not wired
-**ESP-NOW Receiver** (`firmware/master/src/espnow_master.cpp/h`)
- Receive sensor data from Slaves (10Hz)
- Checksum validation (XOR)
- Auto-discovery (no manual pairing)
- Connection timeout detection (1000ms)
- Packet statistics tracking
## What Is Not Finished Yet
- **Web Server** (`firmware/master/src/web_server.cpp/h`)
- AsyncWebServer (non-blocking)
- REST API endpoints:
- GET /api/nodes (sensor data)
- GET /api/differential (EWD calculation)
- POST /api/calibrate (zero sensors)
- GET /api/status (system health)
- JSON responses (ArduinoJson)
- dedicated `firmware/cog_slave`
- HX711 integration
- tare and scale calibration persistence
- model profiles for support spacing and target CoG
- dedicated CoG workflow in the UI
-**Master Main Loop** (`firmware/master/src/main.cpp`)
- WiFi Access Point (SSID: "SkyLogic-AeroAlign")
- IP: 192.168.4.1 (captive portal)
- IMU sampling (100Hz)
- ESP-NOW updates (100ms)
- Battery monitoring (1Hz)
- Status reporting (10s intervals)
## Recommended Next Step
#### Firmware Foundation - Slave Node
-**IMU Driver** (`firmware/slave/src/imu_driver.cpp/h`)
- Same as Master (copied)
-**ESP-NOW Transmitter** (`firmware/slave/src/espnow_slave.cpp/h`)
- Send sensor data to Master (10Hz)
- 15-byte packet format (node_id, pitch, roll, yaw, battery, checksum)
- Pairing with Master MAC
- Transmission statistics
-**Slave Main Loop** (`firmware/slave/src/main.cpp`)
- IMU sampling (100Hz)
- ESP-NOW transmission (10Hz / 100ms intervals)
- Battery monitoring (1Hz)
- Low battery warning (LED flash)
- Status reporting (10s intervals)
#### Infrastructure
-**Git Ignore** (`.gitignore`)
- PlatformIO build artifacts
- IDE files (VSCode, IntelliJ, Eclipse)
- Environment files (.env)
- OS-specific files (.DS_Store, Thumbs.db)
-**Web UI** (`firmware/master/data/index.html`)
- Real-time angle display (10Hz polling)
- System status dashboard
- Node connection indicators
- Battery/RSSI monitoring
- Responsive design (mobile-friendly)
-**Documentation** (`README.md`)
- Project overview and features
- Quick start guide
- Hardware requirements
- Architecture diagram
- API documentation
- Development instructions
---
### Phase 3: User Story 1 - MVP (12/12 tasks - 100%)
**Web UI Enhancements** (`firmware/master/data/index.html`):
- ✅ Three-tab interface (Sensors, Differential, System)
- ✅ Real-time angle display (10Hz polling)
- ✅ Calibration buttons for each sensor
- ✅ Connection indicators with pulse animation
- ✅ Battery warnings (orange card when <20%)
- ✅ Toast notifications for success/failure
- ✅ Node selectors for differential measurement
- ✅ Color-coded results (green <0.5°, yellow <2.0°, red >2.0°)
- ✅ Responsive mobile design
---
### Phase 4: User Story 2 - Differential Measurement (8/8 tasks - 100%)
**Median Filtering Implementation** (`firmware/master/src/web_server.cpp/h`):
-`DifferentialHistory` data structure
- Circular buffer for last 10 readings per node pair
- Supports up to 36 unique node pairs
- Automatic memory management
-**Median Calculation Algorithm**
- Bubble sort for small arrays (10 elements)
- Handles even/odd sample counts
- Non-destructive (preserves original data)
-**Standard Deviation Calculation**
- Sample standard deviation (n-1 denominator)
- Measures measurement stability
- Color-coded in UI (green <0.1°, yellow <0.3°, red >=0.3°)
-**Enhanced API Response**
- `median_diff`: Median of last 10 pitch readings
- `median_pitch`: Median pitch differential
- `median_roll`: Median roll differential
- `std_dev`: Standard deviation of pitch readings
- `std_dev_pitch`: Pitch standard deviation
- `std_dev_roll`: Roll standard deviation
- `readings_count`: Number of samples in buffer (0-10)
**Web UI Enhancements**:
- ✅ Median value display (primary metric)
- ✅ Current reading display (real-time, unfiltered)
- ✅ Standard deviation indicator (measurement quality)
- ✅ Sample count display (buffer fill status)
- ✅ Color-coded stability feedback
**Accuracy Achievement**:
- ✅ ±0.1° accuracy via median filtering (vs ±0.5° raw IMU)
- ✅ Real-time stability monitoring
- ✅ Configurable history depth (10 samples = 1 second at 10Hz)
---
## 📊 Implementation Metrics
### Code Statistics
**Lines of Code**:
- Master firmware: ~1,500 lines
- Slave firmware: ~600 lines
- Web UI: ~400 lines
- **Total**: ~2,500 lines
**Files Created**: 25+
- Firmware: 12 files
- Hardware: 3 files
- Documentation: 10+ files
### Test Coverage
-**Unit Tests**: Not yet implemented (planned for Phase 7)
-**Integration Tests**: Pending hardware validation
-**API Contract**: Fully documented in contracts/
---
## 🔧 What Works Now
### Firmware Features
1. **Master Node**:
- WiFi Access Point active
- REST API responding to HTTP requests
- ESP-NOW receiver listening for Slaves
- IMU reading pitch/roll angles
- Calibration stored to NVS
- Battery monitoring active
2. **Slave Node**:
- ESP-NOW transmitter sending data
- IMU sampling at 100Hz
- Battery percentage calculated
- Low battery warnings
- Connection status LED
3. **Web Interface**:
- Real-time angle display
- System status dashboard
- Connection indicators
- API endpoint links
### Testing Status
**Compilation**: ✅ Both Master and Slave compile successfully
**Runtime**: ⏳ Awaiting hardware testing
**API**: ✅ Endpoints respond with proper JSON
---
## 🚧 What's Next (Phase 5: User Story 3)
### Immediate Tasks (8 remaining)
1. **Multi-Node Support** (T041-T043):
- Support 4-6 simultaneous sensor nodes
- Implement scrollable node list in UI
- Add node discovery status indicators
2. **Enhanced Node Management** (T044-T046):
- Node labeling/naming functionality
- Connection quality indicators
- Battery status for all nodes
3. **System Scalability** (T047-T048):
- Optimize web UI for multiple nodes
- Test with 6 physical nodes
- Performance validation
### Hardware Validation
**Required Equipment**:
- 2× ESP32-C3 DevKits
- 2× MPU6050 IMU modules
- 2× LiPo batteries (250-400mAh)
- USB-C cables
- Breadboard + jumper wires
**Test Procedure**:
1. Flash Master firmware
2. Note Master MAC address from serial output
3. Update Slave config.h with Master MAC
4. Flash Slave firmware
5. Power on both nodes
6. Connect smartphone to "SkyLogic-AeroAlign" WiFi
7. Open http://192.168.4.1
8. Verify real-time angle updates
---
## 💡 Key Achievements
### Technical Excellence
1. **Auto-Discovery**: Slaves automatically register with Master (no manual pairing)
2. **Low Latency**: <20ms ESP-NOW transmission + 100ms web UI refresh = <120ms total
3. **Robust Protocol**: Checksum validation prevents corrupted data
4. **Persistent Calibration**: NVS storage survives power cycles
5. **Multi-Node Ready**: Architecture supports 8 sensors (Phase 8)
### Constitution Compliance
**Cost-Efficiency**: $72 for 2-sensor system (vs. $600 competitors)
**3D Printing**: All parts <200mm³, <30% support
**Lightweight**: Target 23g per node (vs. 25g spec)
**Plug-and-Play**: 3-step setup (power, WiFi, browser)
---
## 🐛 Known Issues
1. **Master MAC Hardcoding**: Slave requires manual MAC entry in config.h
- **Impact**: Medium (one-time setup)
- **Workaround**: Serial monitor shows Master MAC
- **Fix**: Phase 8 auto-discovery feature
2. **Web UI Placeholder**: Basic HTML/JS (not full React)
- **Impact**: Low (functional but not polished)
- **Status**: Phase 3 will add React components
3. **No Physical Testing**: Firmware untested on hardware
- **Impact**: High (may have runtime bugs)
- **Status**: Awaiting hardware delivery
4. **Missing STL Files**: 3D models documented but not created
- **Impact**: Medium (blocks physical assembly)
- **Status**: Requires FreeCAD design (Phase 7)
---
## 📈 Timeline Estimate
**Completed** (Phases 1-4): ~14 hours
- Phase 1-2 (Setup + Foundation): ~8 hours
- Phase 3 (MVP): ~3 hours
- Phase 4 (Differential): ~3 hours
**Remaining**:
- Phase 5-6 (US3-US4): 6-8 hours
- Phase 7 (Polish): 6-8 hours
- Phase 8 (Multi-Sensor): 10-12 hours
**Total Project**: ~40-50 hours for full feature set
---
## 🎯 Next Session Goals
1. **Hardware testing** with 2 physical nodes (validate Phase 3-4 implementation)
2. **Phase 5**: Multi-node support (4-6 sensors)
- Implement scrollable node list in web UI
- Add node labeling functionality
- Test with multiple Slave nodes
3. **Phase 6**: Throw gauge mode (control surface deflection)
4. **3D Printing**: Generate STL files for sensor housing
5. **Documentation**: Assembly guides and troubleshooting
---
**Status**: MVP + Differential Measurement complete! Ready for multi-node expansion. 🚀
Implement the actual CoG node firmware next, because the protocol, Master-side data path and baseline documentation are now in place.