-
Notifications
You must be signed in to change notification settings - Fork 1
/
accelerometer_env.py
33 lines (26 loc) · 1.33 KB
/
accelerometer_env.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Accelerometer Integration
# Objective: Position detection with velocity derived through acceleration
# Key Components: 1) Model acceleration as measured by the Accelerometer
# 2) Integrate Acceleration to determine velocity
# Assumptions: - Sample Measured position with 0.01km/hr^2 standard deviation
from soumil_env import KalmanFilter
from soumil_env import Sampler
import numpy as np
import matplotlib.pyplot as plt
class Accelerometer:
def __init__(self, total_time, time_step):
self.total_time = total_time
self.time_step = time_step
self.no_steps = int(total_time / time_step + 1)
self.time = np.linspace(0, self.total_time, self.no_steps)
self.true_acceleration = np.zeros(self.no_steps)
self.measured_acceleration = np.zeros(self.no_steps)
self.calculate_acceleration = np.zeros(self.no_steps)
self.kalman_velocity = np.zeros(self.no_steps)
self.accceleration_measure = None
self.error_kalman_true = np.zeros(self.no_steps)
self.error_calculate_true = np.zeros(self.no_steps)
self.error_measure_true = np.zeros(self.no_steps)
self.kalman_filter = KalmanFilter()
parser = argparse.ArgumentParser()
parser.add_argument("--sensors", nargs = '+', type = float, help = "position_deviation")