|
SDK for TESAIoT Dev Kit
API reference & tutorials (ModusToolbox)
|
MicroPython examples are mtb-mpy only; the C-side reduction and the on-screen observables apply to both variants. The C fragments here are written against the public API in ai_engine.h; complete examples are template/proj_cm55/examples/edge_ai/03_parallel_set_run.c and 04_set_membership.c.
Run several models at once as a set, read a verdict from the set without losing detections, and recognise the settle period that withholds verdicts for a few seconds after a set starts. The single most important sentence: ai_engine_snapshot() is not valid inside a set.
Set constants (ai_engine.h): MIC = 255, ROOM = 254, INTRUDER = 253, ALL = 252, AI_PARALLEL_FIRST = ALL. The legacy 13/14/15 aliases resolve to 253/254/255 (Chapter E1). The engine accepts a set index only in an image built with at least one microphone model; otherwise ai_engine_start() returns false.
Set members. ai_engine_set_models() returns the members in effect: an explicit membership given with ai_engine_set_define() replaces the compiled one; otherwise the compiled membership applies. A model whose init() failed once is not dropped from the set for the boot — the next start of the set tries it again.
Custom membership — edge_ai.set_define(set, [i, j, ...]) resolves the legacy index, sends SET_BEGIN, one SET_ADD per member and SET_COMMIT, then reads the membership back with Q_SET — the read-back is the only thing that catches a dropped ADD. CM55 applies the definition whole on SET_COMMIT. The C side does the same in two calls, and the read-back is the only acknowledgement:
Result reduction inside a set — the loudest positive member, via ai_engine_set_members() + ai_engine_snapshot_model() + ai_result_top_positive():
Over the model link each class score is reported as 0..100 (score_pct in the Q_RESULT response); class_count == 0 means "no verdict yet", and edge_ai.result() returns None.
Sensor-rate side effect. Starting a set that contains an IMU model raises the accelerometer to 50 Hz for the session. ai_engine_model() returns NULL for a set pseudo-index, so branch on idx >= AI_PARALLEL_FIRST first:
On screen, open the model dropdown on the Edge AI page. Rows for sets are added only when the set has at least two members and ai_engine_set_name() returns a non-NULL name.
What you should observe. Set rows (Sound Watch, Room Presence, Intruder Watch, All Models) appear after the compiled single models. A set with fewer than two members in this image is simply absent — that is a build-content fact, not a fault.
What you should observe. For the first seconds result() returns None — class_count == 0 — while the set's inputs settle. On screen the verdict label reads filling windows lu%% with the percentage climbing, and the badge shows Loading. On the C side the calls are ai_engine_mic_settling() / ai_engine_mic_settle_pct():
Keep diagnostics visible during the settle period too: the Edge AI page's stats line keeps updating through it, so an NPU stall in that period is not hidden. mic_settle_pct() is meaningful only inside a set; it returns 100 otherwise.
What you should observe. Once settled, a result whose fields come from the loudest positive member. Each member row on screen carries its own silence timer, counted from how long that member's seq has not advanced:
ai_engine_snapshot_model() returning false means "never published", which is not the same as "silent"; the index must be a real registry index, never a set pseudo-index.
What you should observe. set_define returns after the Q_SET read-back confirms every member; a dropped ADD shows up as a shorter list, and the whole definition is refused if any index is invalid (all-or-nothing). Membership is 1..8 entries. set_define(252, ...) always fails — AI_PARALLEL_ALL is every registered model by definition and cannot be redefined; only INTRUDER, ROOM and MIC can.
What you should observe. Nothing visible — this is the discipline that keeps the layout tag and the row count from disagreeing when the model link starts or stops the engine from another task mid-render.
| mtb-mpy | mtb-only | |
|---|---|---|
| Select a set | edge_ai.select(252..255) | Dropdown row + Load |
| Define membership | edge_ai.set_define() | Only via your own CM55 code calling ai_engine_set_define() from a task; read back with ai_engine_set_members_defined() |
| Settle observable | result() is None; screen filling windows lu%% | Screen filling windows lu%% |
| Verdict | edge_ai.result() dict | Verdict label + per-row silence timers |