From d483967b52ab8b2cc142c5ba633ec9a628960ee6 Mon Sep 17 00:00:00 2001 From: mgrouch Date: Sun, 13 Nov 2022 05:21:55 -0500 Subject: [PATCH] kalman with integral drift correction (adj mean) --- rust/src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rust/src/main.rs b/rust/src/main.rs index b063913..c1f1512 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -30,6 +30,10 @@ fn get_f64(record: &StringRecord, index: usize) -> f64 { record.get(index).expect(&*format!("Missing field {index}")).trim().parse::().unwrap() } +fn mean(numbers: &Vec) -> f64 { + numbers.iter().sum::() as f64 / numbers.len() as f64 +} + fn main() { let (time, acc, pos, _ /*vel*/) = read_data("../test-data.txt"); @@ -69,7 +73,7 @@ fn main() { data.push(Vector::new(vec![0.0])); } - let acc_mean = -0.08; // TODO: calculate it + let acc_mean = mean(&acc); // With no integral drift correction let mut predicted: Vec = Vec::with_capacity(n_timesteps+1);