Files
gps/soc/software/tdk_noise_test/Makefile
T
onur cayan 471ff12e70 test(fusion): guard the deadlock and calibration regressions, add noise tool
The existing suite passed both before and after the fusion fixes, so it
never covered either failure. Two tests close that gap; both were checked
against the pre-fix sources and fail there.

calibration_offset_test reproduces the bench part's +28 mg zero-g offset
and requires startup to complete, while still refusing a sustained 3 m/s2
acceleration. It also asserts the blind spot rather than leaving it
implicit: horizontal acceleration adds to gravity in quadrature, so
1.5 m/s2 moves the magnitude by only 0.11 m/s2 and is not separable from
offset by any accelerometer gate. Separating it needs GNSS velocity.

long_outage_trajectory_test drives pedestrian, gentle-car (0-100 km/h in
30 s), slow-city and isolated-mount profiles across 1 and 5 minute
outages, using the production rest supervisor rather than a hand-set
flag. Only the isolated-mount slow-city case reproduces the field bug:
GNSS motion evidence compares displacement against covariance, so 4 m/s
under 6 m sigma scores a displacement NIS of 0.22 against a 9.21 gate and
reads as stationary, whereas highway speed scores 42.9 and is correctly
called moving. Pre-fix that case produces 608 zero-velocity updates while
driving, matching the 609 in the board logs.

Drift is judged against the filter's own covariance rather than a fixed
distance. Five minutes unaided legitimately reaches kilometres on this
hardware; what must not happen is the error outrunning the covariance,
which is divergence rather than honest coasting.

tdk_noise_test characterises the sensor at rest through the production
driver, so ODR, full scale, UI filter and LSB scaling match the flight
build, and reports the norms fusion_motion_update() actually gates on.
It also carries an INT1-to-PLIC continuity test that drives the pin to a
static level and reads the PLIC pending bit directly, separating a broken
line from a source that never fires.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-07 22:06:24 +03:00

40 lines
1.2 KiB
Makefile

TARGET := tdk_noise_test
GPS_SYSTEM_DIR ?= ../gps_system
# The production driver is compiled in directly so the sensor is configured
# exactly as the flight build configures it.
vpath %.c $(GPS_SYSTEM_DIR)/src/drivers/imu
APP_SRCS := \
main.c \
tdk_icm42688.c
BSP_SRCS := init.c uart.c plic.c irq.c pmod_spi.c
# Genesys2 fabric/UART and CLINT defaults, matching the gps_system app.
BSP_UART_CLOCK_HZ ?= 50000000
BSP_UART_BAUDRATE ?= 460800
BSP_CLINT_TIMEBASE_HZ ?= 500000
# Mirrors gps_system IMU_ODR_HZ; override together with it.
NOISE_ODR_HZ ?= 50
NOISE_DISCARD_SAMPLES ?= 100
NOISE_BIAS_SAMPLES ?= 1000
NOISE_MEASURE_SAMPLES ?= 3000
# Set to 1 to refuse the polled fallback, so a broken INT1 route fails loudly.
NOISE_REQUIRE_IRQ ?= 0
# Set to 1 to run only the INT1 -> PLIC continuity test and exit.
NOISE_PIN_TEST ?= 0
include ../common/app.mk
CFLAGS += -I$(GPS_SYSTEM_DIR)/header
CFLAGS += -DNOISE_ODR_HZ=$(NOISE_ODR_HZ)u \
-DNOISE_DISCARD_SAMPLES=$(NOISE_DISCARD_SAMPLES)u \
-DNOISE_BIAS_SAMPLES=$(NOISE_BIAS_SAMPLES)u \
-DNOISE_MEASURE_SAMPLES=$(NOISE_MEASURE_SAMPLES)u \
-DNOISE_REQUIRE_IRQ=$(NOISE_REQUIRE_IRQ) \
-DNOISE_PIN_TEST=$(NOISE_PIN_TEST)
LDLIBS += -lm