Skip to content

IEKF review fixes, cold-start test, log wall clock, USB ground link (fw 0.6.0) - #25

Merged
andrea-cirillo merged 3 commits into
mainfrom
fix/iekf-review-and-app-open-points
Nov 2, 2026
Merged

andrea-cirillo merged 3 commits into
mainfrom
fix/iekf-review-and-app-open-points

Conversation

@andrea-cirillo

@andrea-cirillo andrea-cirillo commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Addresses ACwing_IEKF_HANDOVER_FW.md (c4dynamics notebook review) and the "wall-clock time" point of HANDOVER_APP.md §10.

IEKF (firmware 0.6.0)

  • Tangential innovation (IEKF_TANGENT_INNOV, default on), in vector_update() and in the lockout persistence test. It is mirrored in iekfCore*.m and acwing_tools.filters.embedded, and INIT flag 0x20 makes the comparison follow it. With an isotropic R the radial part is already in the null space of K: the change acts only on the NIS. C, Python and MATLAB agree to 6 digits with it on and off.

  • iekf_reset_attitude() sets an honest P0, clears the inflation and persistence memory and restarts the accelerometer grace period. Use it for any re-init away from rest.

  • app_est_config() moves the production estimator configuration out of app_main.c, so the host test runs the exact values.

  • Cold-start test (make iekf_test, 32 checks) runs the production pipeline from 30°, 90°, 150° and 179° about 6 axes, static and moving:

    • every case converges below 5°;
    • the grace period matters most in motion;
    • the projection is never worse and gives a small gain at 179°.

    The table is in theory/iekf-embedded.md.

  • Docs:

    • iekf.md: H depends on R̂ and F on b̂; "converges from any initial attitude" is removed;
    • ADR 0001 reworded;
    • roadmap items 7–9.
    • validation.md: a board re-baseline is needed.

Flight log wall clock

  • SET_TIME (0x43) over USB and BLE. The LogTask keeps the clock as an offset from the uptime and does not pause the recording.
  • LR_TIME (0x02) is written after LR_INFO and when the clock is set. The log format stays 1, because unknown types are skipped.
  • Python: decodes the record, shows the date in the summary, and log sets the time before listing.
  • MATLAB: decodes the record; the download sets the time.
  • App: sends SET_TIME at connection, the simulator records LR_TIME, and the viewer shows "Flown …" (5 languages).
  • Docs and contract: HANDOVER_FW.md and HANDOVER_APP.md §10 are updated.

USB as a ground link (ADR 0009)

  • What USB carries: telemetry, parameters, calibrations and the log, never flight commands.
    • ARM, KILL, RC, TAKEOFF, LAND, MOTOR_TEST and the other flight commands are answered REJECTED / NOT_OVER_USB (18).
    • USB never feeds the app-link failsafe.
  • No arming with a computer attached: while a USB host is connected, ARM, TAKEOFF and MOTOR_TEST are refused from any link with USB_CONNECTED (17).
    • CHECKS item 12 (USB) is in FAIL.
    • DISARM, LAND and KILL always work.
  • The first link opened has control of the settings. Changes from the other link get OTHER_LINK (19).
    • Telemetry and events go to both links; each ACK goes only to the link of its command.
    • A calibration started over USB is aborted when USB closes.
  • Transport: one TX ring per producer (LogTask, AppTask, TelemetryTask), drained only at frame boundaries.
    • DTR is read from the CDC control request.
    • PC telemetry (STATE, INIT, STATUS) goes to USB when a program has the port open.
  • App: reasons 17–19 and check 12 added (5 languages, simulator). A Drone over Web Serial is left to HANDOVER_APP.md §10.
  • Docs and contract: HANDOVER_FW.md §5.2, ADR 0009, protocol, logging, testing, roadmap.

Checks

  • Host tests: 93 + 12 + power 95 + log 63 + link 35 + iekf 32. App decoders vs firmware frames: 0 mismatches.
  • Python and app: Python 33, app 37.
  • ARM build: debug 217 KB, -Os 121 KB. RAM +10 KB for the USB rings.
  • Docs: mkdocs --strict and Doxygen give 0 warnings.

Still to do on the board:

  • a mode-0 capture with firmware 0.6 to re-baseline the IEKF validation;
  • SET_TIME from the app;
  • USB enumeration and DTR, PC telemetry over USB, and ARM refused with the cable in.

https://claude.ai/code/session_0153J9kBPssb6AoMEdTtrvbo


Generated by Claude Code

From the c4dynamics notebook review (ACwing_IEKF_HANDOVER_FW, items 1-9).

- vector_update() and the persistence test use only the part of y - yhat
  tangent to yhat (IEKF_TANGENT_INNOV, default on). For an isotropic R the
  radial part is in the null space of K, so it only removed a spurious
  (1 - cos e)^2 / sigma^2 term from the NIS. Mirrored in iekfCore*.m and in
  the Python port; INIT flag 0x20 so old captures still compare exactly.
  C, Python and MATLAB agree to 6 digits with it on and off.
- iekf_reset_attitude(): any re-initialisation away from rest sets an
  honest P0 and restarts the accelerometer grace period.
- app_est_config(): the estimator configuration out of app_main.c, so the
  host test runs exactly the production values.
- Tests/host/test_iekf.c (make iekf_test): cold start from 30/90/150/179
  deg about 6 axes, static and moving, with and without the projection,
  with production P0 and without the grace period. All converge; the
  grace period matters most, the projection gives a small gain at 179 deg.
- Docs: H depends on R_hat, F on the bias estimate, no "converges from any
  attitude"; ADR 0001 reworded (quaternion MEKF equivalent, right-invariant
  error as an option); roadmap items 7-9; re-baseline on the board needed.
- Firmware 0.6.0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0153J9kBPssb6AoMEdTtrvbo
HANDOVER_APP section 10, "wall-clock time in the log".

- PV2_OP_SET_TIME 0x43 (unix_s, ms, tz_min), over USB and over BLE
  (forwarded by the AppTask). The LogTask owns the clock as an offset from
  the uptime; it is lost at reset. It does not pause the recording.
- LR_TIME 0x02 after LR_INFO of every new log and in the open log when the
  clock is set. New record type, format stays 1: old readers skip it.
- Python (decode, summary date, set_time before listing), MATLAB (decode,
  download sets the time), app (sends SET_TIME at connection, simulator,
  decoder, flight date in the viewer, 5 languages).
- log_test 63 checks; new firmware sample log for the Python and app tests.
- HANDOVER_FW contract and HANDOVER_APP section 10 updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0153J9kBPssb6AoMEdTtrvbo
@github-project-automation github-project-automation Bot moved this to Backlog in @ACwing Nov 2, 2026
…h USB

HANDOVER_APP section 10 "USB as a flight link", as decided: USB never flies
the drone (ADR 0009).

- usb_link: one SPSC TX ring per producer (LogTask, AppTask,
  TelemetryTask), drained at frame boundaries; host state (configured, DTR);
  usbl_open() = host and (DTR or a command in the last 3 s).
- usb_cdc: DTR from SET_CONTROL_LINE_STATE, configured state each pump,
  2 KB transfers.
- LogTask keeps LOG_*, SET_TIME and the heartbeat; every other USB command
  goes to the AppTask through an SPSC queue.
- AppTask over USB: PARAM_*, CAL_*, STREAM_RATES, REQUEST, SET_NAME only;
  flight commands -> REJECTED / NOT_OVER_USB (18). Telemetry and events to
  both links, ACKs to the link of the command (separate ACK-cache entries).
  The first link opened has control of the configuration; the other one
  gets REJECTED / OTHER_LINK (19) on changes. A calibration started over USB
  is aborted when USB closes.
- Flight core: ARM, TAKEOFF and MOTOR_TEST refused with USB_CONNECTED (17)
  while a USB host is connected, from any link; CHECKS item 12 USB.
- TelemetryTask: STATE / INIT / STATUS to USB when a program has the port
  open (APP_USB_TLM), for boards without a debug probe.
- Host test link_test (35 checks); app: reasons 17-19, check 12, 5 languages,
  simulator; HANDOVER_FW 5.2, ADR 0009, protocol, logging, testing, roadmap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0153J9kBPssb6AoMEdTtrvbo
@andrea-cirillo andrea-cirillo changed the title IEKF review fixes, cold-start test, flight-log wall clock (fw 0.6.0) IEKF review fixes, cold-start test, log wall clock, USB ground link (fw 0.6.0) Nov 2, 2026
@andrea-cirillo
andrea-cirillo merged commit 8555688 into main Nov 2, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in @ACwing Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants