You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add telemetry pipeline with REPL output for PID tuning (M2a pre-hardware)
Expose PID term contributions (last_p/last_i/last_d) for logging,
add TelemetryRecorder with pluggable sink (PrintSink now, SdSink when
Adalogger arrives), wire into main loop with configurable decimation.
Validated on hardware — CSV output confirmed via REPL.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
-`T_RTC` — Wall clock from PCF8523 (ISO 8601, second resolution)
85
-
-`T_MS` — `ticks_ms` since boot (sub-ms precision for inter-sample timing)
84
+
-`T_MS` — `ticks_ms` since boot (sufficient without RTC; `T_RTC` column added as first column when Adalogger hardware arrives)
86
85
-`ENC_DEG` — AS5600 angle in degrees (ground truth)
87
-
-`IMU_DEG` — BNO085 angle in degrees (when available, empty otherwise)
86
+
-`IMU_DEG` — BNO085 angle in degrees (empty until M2)
88
87
-`ERR` — PID error term
89
88
-`P`, `I`, `D` — Individual PID contributions
90
-
-`M1`, `M2` — Motor throttle values
89
+
-`PID_OUT` — Raw PID output before clamping to motor range (shows PID saturation)
90
+
-`M1`, `M2` — Motor throttle values (integers)
91
91
92
92
### Write strategy
93
93
@@ -109,6 +109,19 @@ SD card root/
109
109
110
110
Each file gets a header row on creation. RTC timestamp in the first data row provides the wall clock reference; subsequent rows use `T_MS` deltas for precise inter-sample timing.
111
111
112
+
### Sampling & decoupling
113
+
114
+
The telemetry pipeline separates data collection from I/O through a facade pattern:
115
+
116
+
-**`TelemetryRecorder`** — facade called from the main loop. Accepts all telemetry fields per cycle, handles decimation, and delegates output to a pluggable sink.
117
+
-**`PrintSink`** — current backend. Prints CSV rows to REPL serial console. No buffering needed.
118
+
-**`SdSink`** (future) — buffers N rows in RAM, flushes to SD card file. Plug in when Adalogger hardware arrives — no structural changes to main loop or recorder.
119
+
120
+
Configurable decimation via `TELEMETRY_SAMPLE_EVERY` constant in `main.py`:
121
+
- Set high (e.g., 10000) for REPL output to avoid serial flood
122
+
- Set to 1–5 for SD card logging to capture full-rate data
123
+
- Decimation is cycle-count based: every N-th call to `record()` emits a row
0 commit comments