# HG changeset patch # User Simon Heath # Date 1656002783 14400 # Thu Jun 23 12:46:23 2022 -0400 # Node ID baaf9593b8b844cd4b2b0e12babb6ab0ec569561 # Parent aa355cd7298c612f4253a8aa3bc544845ece5fa9 Starting kalman filter cleanup diff --git a/apps/goatherd/src/alg_kalman.erl b/apps/goatherd/src/alg_kalman.erl --- a/apps/goatherd/src/alg_kalman.erl +++ b/apps/goatherd/src/alg_kalman.erl @@ -14,17 +14,31 @@ %% https://www.kalmanfilter.net/ %% %% +%% Ok to make life simpler for expository purposes we're just gonna use a +%% 1D position model. Once it works we can try to generalize it -module(alg_kalman). -export([run/0]). -% Ok to make life simpler for expository purposes we're just gonna use a -% 1D position model - -record(state, {x, vx}). -record(uncertainty, {err_x, err_vx}). +%% Abortive attempt to generalize the algorithm. +%% TODO NEXT: Work on making all the functions take/return +%% a #state{} and #val{}. +%% A single value/dimension that the predictor operates on +%-record(val, {v, err}). + +%% The whole state of the predictor. +%% This requires models for predicting the state and error, +%% which will depend on this whole state. Each field of this is one +%% #val{}. +%% +%% Each measurement must be this whole state, and each +%% step of the filter will return a new copy of this state. +%-record(state, {x , vx}). + %% Kalman Gain is also written Kn. %% %% These are all independent of what model we use so we just do a single @@ -122,6 +136,8 @@ {EstimatedState, EstimatedErr}. + + run() -> InitialState = #state { x = 0.0, vx = 0.0 }, InitialErr = #uncertainty { err_x = 0.1, err_vx = 0.1 },