-
Notifications
You must be signed in to change notification settings - Fork 31
/
assignment3.py
48 lines (38 loc) · 1.28 KB
/
assignment3.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import numpy as np
from sim.sim2d import sim_run
# Simulator options.
options = {}
options['FIG_SIZE'] = [8,8]
options['DRIVE_IN_CIRCLE'] = False
# If False, measurements will be x,y.
# If True, measurements will be x,y, and current angle of the car.
# Required if you want to pass the driving in circle.
options['MEASURE_ANGLE'] = False
options['RECIEVE_INPUTS'] = False
class KalmanFilter:
def __init__(self):
# Initial State
self.x = np.matrix([[0.],
[0.]])
# Uncertainity Matrix
self.P = np.matrix([[0., 0.],
[0., 0.]])
# Next State Function
self.F = np.matrix([[0., 0.],
[0., 0.]])
# Measurement Function
self.H = np.matrix([[0., 0.]])
# Measurement Uncertainty
self.R = np.matrix([[0.0]])
# Identity Matrix
self.I = np.matrix([[1., 0., 0., 0.],
[0., 1., 0., 0.],
[0., 0., 1., 0.],
[0., 0., 0., 1.]])
def predict(self, dt):
return
def measure_and_update(self,measurements, dt):
return [self.x[0], self.x[1]]
def recieve_inputs(self, u_steer, u_pedal):
return
sim_run(options,KalmanFilter)