Skip to content

Commit 99c7849

Browse files
committed
Use matrix multiplication instead of elementwise
1 parent b80b7c9 commit 99c7849

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

SLAM/EKFSLAM/ekf_slam.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@
309309
" G, Fx = jacob_motion(xEst[0:S], u)\n",
310310
" # Fx is an an identity matrix of size (STATE_SIZE)\n",
311311
" # sigma = G*sigma*G.T + Noise\n",
312-
" PEst[0:S, 0:S] = G.T * PEst[0:S, 0:S] * G + Fx.T * Cx * Fx\n",
312+
" PEst[0:S, 0:S] = G.T @ PEst[0:S, 0:S] @ G + Fx.T @ Cx @ Fx\n",
313313
" return xEst, PEst, G, Fx"
314314
]
315315
},
@@ -584,7 +584,7 @@
584584
" [0.0, 0.0, DT * u[0] * math.cos(x[2, 0])],\n",
585585
" [0.0, 0.0, 0.0]])\n",
586586
"\n",
587-
" G = np.eye(STATE_SIZE) + Fx.T * jF * Fx\n",
587+
" G = np.eye(STATE_SIZE) + Fx.T @ jF @ Fx\n",
588588
" if calc_n_LM(x) > 0:\n",
589589
" print(Fx.shape)\n",
590590
" return G, Fx,\n",

SLAM/EKFSLAM/ekf_slam.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def ekf_slam(xEst, PEst, u, z):
3131
S = STATE_SIZE
3232
xEst[0:S] = motion_model(xEst[0:S], u)
3333
G, Fx = jacob_motion(xEst[0:S], u)
34-
PEst[0:S, 0:S] = G.T * PEst[0:S, 0:S] * G + Fx.T * Cx * Fx
34+
PEst[0:S, 0:S] = G.T @ PEst[0:S, 0:S] @ G + Fx.T @ Cx @ Fx
3535
initP = np.eye(2)
3636

3737
# Update
@@ -119,7 +119,7 @@ def jacob_motion(x, u):
119119
[0.0, 0.0, DT * u[0] * math.cos(x[2, 0])],
120120
[0.0, 0.0, 0.0]])
121121

122-
G = np.eye(STATE_SIZE) + Fx.T * jF * Fx
122+
G = np.eye(STATE_SIZE) + Fx.T @ jF @ Fx
123123

124124
return G, Fx,
125125

0 commit comments

Comments
 (0)