8 Commits
Author SHA1 Message Date
Fabien Carrion 9c6a72cee9 feat(s5max): add documentation 2026-09-19 12:19:42 -06:00
codetiger d789cb743f Add lidar PWM auto-tuning and optimize binary sizes
Lidar auto-tuning:
- Implement adaptive binary-search algorithm to find max stable PWM
- Start at 100% PWM, ramp down with 20% steps, halve on direction reversal
- Converge when step reaches 2% and scans are stable (typically ~75%)
- Add settling detection via timeout (250ms) or health packet count (3)
- Share scan timestamps and health counts between GD32/Delta2D drivers
- Add recovery mode to handle unexpected scan loss
- Remove manual PWM configuration (Configure action now ignored)
- Document auto-tuning algorithm in COMMANDS.md

Binary size optimization:
- Disable default features for serde, prost, rand, image, env_logger
- Replace toml crate with basic-toml (no toml_edit/winnow)
- Disable serialport libudev feature (not needed on embedded Linux)
- Add size-optimized release profiles (opt-level=z, LTO, panic=abort)
- Remove NEON rustflags from .cargo/config.toml (caused issues)
2025-12-07 07:48:59 +05:30
codetiger 0ab78b6380 Improve documentation for device driver extensibility
Update CLAUDE.md, module docs, and READMEs to reflect current
architecture and provide clearer guidance for adding new device
implementations. Key changes:

- Add comprehensive DeviceDriver trait documentation with examples
- Document module structure and factory pattern in devices/mod.rs
- Update file path references to reflect crl200s/ organization
- Change configuration example from TOML to JSON format
- Fix minor documentation inconsistencies across READMEs
2025-12-01 10:17:09 +05:30
codetiger 7dfe9fa48b Add ProtocolSync command and improve MITM logging format
SangamIO changes:
- Add ProtocolSync command (0x0C) for GD32 wake sequence at boot
- Add CMD_PROTOCOL_SYNC constant and cmd_protocol_sync() builder
- Handle protocol sync ACK in reader loop with logging
- Update COMMANDS.md with full AuxCtrl init sequence from MITM capture

Protocol-MITM changes:
- Simplify log format to CSV for easier parsing and analysis
- Configure PTY slave for raw mode to prevent escape encoding
- Remove verbose packet decoding (now done in post-processing)
- Update documentation with new CSV format specification

Other:
- Add *.log to gitignore
- Remove unused mitm_init.sh script
- Update deployment scripts for simplified workflow
2025-11-27 15:55:56 +05:30
codetiger 6a5947ad8b Rewrite Drishti UI and refactor SangamIO architecture
Drishti v2.0.0:
- Full-screen robot diagram with physically-correct layout
- All 13 sensors overlaid on diagram with visual indicators
- JSON protocol support (replaces MessagePack)
- Simplified single-widget architecture
- Removed old 4-panel layout and complex widget hierarchy

SangamIO v0.3.0:
- JSON wire format with length-prefixed framing
- DeviceDriver trait with send_command interface
- Full command set: Motion, Actuator, Sensor Config, Safety, Lifecycle
- Refactored to modular CRL-200S device support

Documentation:
- Consolidated READMEs to root directory
- Updated for JSON protocol and new architecture
- Drishti README focused on diagnostic tool usage
2025-11-22 17:09:48 +05:30
codetiger dfc636f500 Refactor to daemon architecture with TCP streaming and add Drishti client
Major architectural transformation from library to standalone daemon with significant cleanup and optimization.

## Architecture Changes
- Transform SangamIO from library to standalone daemon with TCP interface
- Remove Transport trait abstraction (direct SerialTransport implementation)
- Simplify to single LidarDriver trait (remove unnecessary abstractions)
- Add streaming module with TCP publisher/receiver using MessagePack protocol
- Implement lock-free data flow with crossbeam channels

## New Features
- TCP streaming on ports 5555 (telemetry) and 5556 (commands)
- Real-time telemetry broadcasting at 500Hz
- Lidar scan streaming at 5Hz
- Command reception for motion and actuator control
- Drishti Python client with console and GUI interfaces
- Real-time visualization with PyQt5 GUI

## Performance Optimizations
- Binary size reduced by ~30% (500KB → 350KB)
- Eliminate 12KB allocation per lidar scan via ownership transfer
- TCP publisher buffer reuse (1500+ allocations/sec eliminated)
- Lidar parsing buffer reuse (per-scan heap allocation eliminated)
- Memory usage <10MB RSS, CPU usage <1% on ARM

## Cleanup
- Remove unused dependencies: libc, ctrlc, anyhow
- Remove old library code (motion/, odometry.rs, types/, transport/)
- Remove obsolete examples and documentation
- Delete 390MB+ of old protocol capture logs
- Remove duplicate Cargo.toml sections

## Documentation
- Add focused documentation: PROTOCOL.md, DEPLOYMENT.md, ARCHITECTURE.md
- Rewrite README with daemon-focused quickstart
- Add comprehensive CLAUDE.md with deployment instructions
- Update CHANGELOG with detailed v0.2.0-dev notes

## Breaking Changes
- No longer a library (binary-only daemon)
- All hardware access via TCP protocol
- Configuration file required (sangamio.toml)

Version: SangamIO v0.2.0-dev, Drishti v1.0.0
2025-11-14 15:02:50 +05:30
shankar-gpio 568e6754d9 Refactor documentation and enhance GD32 protocol implementation
Consolidate protocol specifications into source code, improve GD32 command accuracy based on AuxCtrl reverse engineering, and add comprehensive integration test covering all robot components. This update improves documentation maintainability and code correctness.
2025-11-09 18:03:13 +05:30
codetiger 71b3163197 Add protocol MITM tools and implement verified GD32/lidar initialization sequences
This commit adds a complete protocol reverse-engineering toolkit and rewrites
the GD32/lidar drivers based on captured real-world AuxCtrl behavior:

**Protocol MITM Infrastructure** (protocol-mitm/):
- Serial port interception logger in Rust
- Robot-side automation scripts for capturing sessions
- Development tools for log analysis and packet parsing
- Complete session captures showing initialization sequences

**GD32 Driver Improvements**:
- Implement exact AuxCtrl initialization sequence from MITM analysis:
  * CMD=0x0C init sync, 0x8D LED, 0x07 version, 0x65 motor type, 0x71 telemetry
  * Precise timing: LED burst at T+245ms, wake at T+253ms, brushes at T+280ms
  * Heartbeat starts at T+289ms with proper telemetry queries
- Add CMD=0x06 wake command every ~250ms (matches AuxCtrl frequency)
- Enhanced logging for TX/RX packet debugging
- Wait for STATUS_DATA confirmation after init

**Delta-2D Lidar Driver Improvements**:
- Fix packet parsing: wait for complete payload+CRC before reading
- Add detailed logging of bytes available and packet structure
- Implement proper data arrival detection (matches Python reference)

**Example Program Updates** (test_lidar_scenario.rs):
- Complete lidar power-on sequence: mode switch → prep → power → PWM
- Proper initialization delays (1.4s stabilization matches AuxCtrl)
- Graceful shutdown with PWM ramp-down before power-off

**Documentation & Security**:
- Replace hardcoded passwords with $ROBOT_PASSWORD environment variable
- Update all deployment guides with MITM tool references
- Add protocol-mitm/ section to README

**Build Optimizations** (Cargo.toml):
- Enable LTO, strip symbols, single codegen unit, panic=abort
- Reduces binary size significantly for embedded deployment

**Cleanup**:
- Remove obsolete serial_dump.rs (replaced by protocol-mitm tools)

This work enables reliable GD32 and lidar operation by following the exact
command sequences and timing used by the original AuxCtrl firmware.
2025-11-02 17:25:07 +05:30