Skip to content

File syn_kalman.c

FileList > dsp > syn_kalman.c

Go to the source code of this file

General-purpose fixed-point Kalman filter implementation. More...

  • #include "../util/syn_assert.h"
  • #include "syn_kalman.h"
  • #include <string.h>

Public Functions

Type Name
SYN_Status syn_kalman_init (SYN_Kalman * kf, const SYN_Kalman_Config * cfg)
Initialize the Kalman filter.
void syn_kalman_predict (SYN_Kalman * kf)
Predict step: propagate state and covariance forward.
SYN_Status syn_kalman_update (SYN_Kalman * kf, const SYN_Matrix * z)
Update step: incorporate a measurement.

Detailed Description

All operations use caller-owned SYN_Matrix instances. No heap allocation. Uses int64_t accumulator matrix multiply for full Q16 precision.

Public Functions Documentation

function syn_kalman_init

Initialize the Kalman filter.

SYN_Status syn_kalman_init (
    SYN_Kalman * kf,
    const SYN_Kalman_Config * cfg
) 

The caller must have populated cfg->F, cfg->H, cfg->Q, cfg->R, and initial cfg->x and cfg->P before calling this. Scratch matrices must be assigned via SYN_KALMAN_SCRATCH_ASSIGN.

Parameters:

  • kf Kalman filter instance.
  • cfg Configuration (caller-owned, must outlive kf).

Returns:

SYN_OK on success, SYN_INVALID_PARAM on dimension mismatch.


function syn_kalman_predict

Predict step: propagate state and covariance forward.

void syn_kalman_predict (
    SYN_Kalman * kf
) 

After this call: * x̂⁻ = F · x̂ (state predicted forward) * P⁻ = F · P · Fᵀ + Q (covariance grows)

Parameters:

  • kf Kalman filter instance.

function syn_kalman_update

Update step: incorporate a measurement.

SYN_Status syn_kalman_update (
    SYN_Kalman * kf,
    const SYN_Matrix * z
) 

After this call: * x̂ is corrected toward the measurement * P is reduced (uncertainty decreased)

Parameters:

  • kf Kalman filter instance.
  • z Measurement vector (n_meas × 1).

Returns:

SYN_OK on success, SYN_ERROR if innovation covariance is singular.



The documentation for this class was generated from the following file src/syntropic/dsp/syn_kalman.c