@@ -24,27 +24,28 @@ def __init__(self, dt, u_x, u_y, std_acc, x_std_meas, y_std_meas, initial_state)
24
24
self .dt = dt
25
25
26
26
# Define the control input variables
27
- self .u = np .matrix ([[u_x ], [u_y ]])
27
+ self .u = np .array ([[u_x ], [u_y ]])
28
28
29
29
# Intial State
30
- self .x = np .matrix ([initial_state [0 ], initial_state [1 ], [0 ], [0 ]])
30
+ initial_state = np .array (initial_state )
31
+ self .x = np .array ([[float (initial_state [0 ])], [float (initial_state [1 ])], [0.0 ], [0.0 ]])
31
32
32
33
# Define the State Transition Matrix A
33
- self .A = np .matrix (
34
+ self .A = np .array (
34
35
[[1 , 0 , self .dt , 0 ], [0 , 1 , 0 , self .dt ], [0 , 0 , 1 , 0 ], [0 , 0 , 0 , 1 ]]
35
36
)
36
37
37
38
# Define the Control Input Matrix B
38
- self .B = np .matrix (
39
+ self .B = np .array (
39
40
[[(self .dt ** 2 ) / 2 , 0 ], [0 , (self .dt ** 2 ) / 2 ], [self .dt , 0 ], [0 , self .dt ]]
40
41
)
41
42
42
43
# Define Measurement Mapping Matrix
43
- self .H = np .matrix ([[1 , 0 , 0 , 0 ], [0 , 1 , 0 , 0 ]])
44
+ self .H = np .array ([[1 , 0 , 0 , 0 ], [0 , 1 , 0 , 0 ]])
44
45
45
46
# Initial Process Noise Covariance
46
47
self .Q = (
47
- np .matrix (
48
+ np .array (
48
49
[
49
50
[(self .dt ** 4 ) / 4 , 0 , (self .dt ** 3 ) / 2 , 0 ],
50
51
[0 , (self .dt ** 4 ) / 4 , 0 , (self .dt ** 3 ) / 2 ],
@@ -85,7 +86,7 @@ def update(self, z, flag):
85
86
# use prediction of previous
86
87
z = self .x [0 :2 ] # + (self.dt * self.x[:2])
87
88
88
- S = np .dot (self .H , np .dot (self .P , self .H .T )) + self .R
89
+ S = np .add ( np . dot (self .H , np .dot (self .P , self .H .T )), self .R )
89
90
# Calculate the Kalman Gain
90
91
# K = P * H'* inv(H*P*H'+R)
91
92
K = np .dot (np .dot (self .P , self .H .T ), np .linalg .inv (S )) # Eq.(11)
0 commit comments