Skip to content

Commit 96d8b08

Browse files
committed
Updated kalman_filter input after failed unit tests in Blender 3.3.16
1 parent 6048f2b commit 96d8b08

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

utils/track/kalman_filter_new.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,28 @@ def __init__(self, dt, u_x, u_y, std_acc, x_std_meas, y_std_meas, initial_state)
2424
self.dt = dt
2525

2626
# Define the control input variables
27-
self.u = np.matrix([[u_x], [u_y]])
27+
self.u = np.array([[u_x], [u_y]])
2828

2929
# 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]])
3132

3233
# Define the State Transition Matrix A
33-
self.A = np.matrix(
34+
self.A = np.array(
3435
[[1, 0, self.dt, 0], [0, 1, 0, self.dt], [0, 0, 1, 0], [0, 0, 0, 1]]
3536
)
3637

3738
# Define the Control Input Matrix B
38-
self.B = np.matrix(
39+
self.B = np.array(
3940
[[(self.dt**2) / 2, 0], [0, (self.dt**2) / 2], [self.dt, 0], [0, self.dt]]
4041
)
4142

4243
# 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]])
4445

4546
# Initial Process Noise Covariance
4647
self.Q = (
47-
np.matrix(
48+
np.array(
4849
[
4950
[(self.dt**4) / 4, 0, (self.dt**3) / 2, 0],
5051
[0, (self.dt**4) / 4, 0, (self.dt**3) / 2],
@@ -85,7 +86,7 @@ def update(self, z, flag):
8586
# use prediction of previous
8687
z = self.x[0:2] # + (self.dt * self.x[:2])
8788

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)
8990
# Calculate the Kalman Gain
9091
# K = P * H'* inv(H*P*H'+R)
9192
K = np.dot(np.dot(self.P, self.H.T), np.linalg.inv(S)) # Eq.(11)

0 commit comments

Comments
 (0)