Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean-Leishman committed Oct 15, 2024
1 parent 8c828ad commit 79fc2f4
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ impl DigitalSignal {
}
}

type AccelerometerData = Vec<RawAccelerationData>;
type RawAccelerometerData = Vec<RawAccelerationData>;

struct RawAccelerationData {
x: i32,
y: i32,
z: i32,
timestamp: i32,
is_sensor_active: bool,
}

static kNumAccelerators: i32 = 3;
static kNumAxis: i32 = 3;

#[cfg(test)]
mod tests {
use super::*;
Expand Down
49 changes: 49 additions & 0 deletions lib/localisation/src/preprocessing/accelerometer.rs
Original file line number Diff line number Diff line change
@@ -1 +1,50 @@
//test
pub core::types

trait AcclerometerPreprocessor{
num_reliable_accelerometers_: i32;
reliable_accelerometers_: Vec<i32>;

fn processData(&self, data: core::types::AccelerometerData) -> core::types::AccelerometerData;

fn(handleOutliers(&self, data: core::types::AccelerometerData) -> core::types::AccelerometerData;
}

impl AcclerometerPreprocessor for core::types::AccelerometerData{
fn processData(&self, data: core::types::AccelerometerData) -> core::types::AccelerometerData{
// do some processing
let accelerometer_data: core::types::AccelerometerData;

core::types::kNumAccelerometers.iter().for_each(|i| {
data[i] = data[i] * 2;
magnitude: f32 = 0.0;
core::type::kNumAxis.iter().for_each(|j| {
magnitude += data[i][j] * data[i][j];
});
accelerometer_data[i] = magnitude.sqrt();
});

const clean_accelerometer_data: core::types::AccelerometerData = handleOutliers(accelerometer_data);

return data;
}

fn handleOutliers(&self, data: core::types::AccelerometerData) {
quartiles: Quartiles;
if (num_reliable_accelerometers_ == core::types::kNumAccelerometers) {
quartiles = getQuartiles(data);
}
else if (num_reliable_accelerometers_ == core::types::kNumAccelerometers - 1) {
let filtered_data = Box::new([0.0; core::types::kNumAccelerometers-1]);
core::type::kNumAccelerometers.iter().for_each(|i| {
if (reliable_accelerometers_.contains(i)) {
filtered_data.push(data[i]);
}
});
quartiles = getQuartiles(data);
}
else {
num_reliable_accelerometers_++;
}
}
}

0 comments on commit 79fc2f4

Please sign in to comment.