Starting kalman filter cleanup
1 files changed, 19 insertions(+), 3 deletions(-)

M apps/goatherd/src/alg_kalman.erl
M apps/goatherd/src/alg_kalman.erl +19 -3
@@ 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 @@ step(State, Err, {MeasurementState, Meas
     {EstimatedState, EstimatedErr}.
 
 
+
+
 run() ->
     InitialState = #state { x = 0.0, vx = 0.0 },
     InitialErr = #uncertainty { err_x = 0.1, err_vx = 0.1 },