Skip to content

Commit e0c1529

Browse files
committed
2 parents a33110a + 5922987 commit e0c1529

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

SLAM/GraphBasedSLAM/graph_based_slam.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ def calc_edge(x1, y1, yaw1, x2, y2, yaw2, d1,
8383

8484
edge.e[0, 0] = x2 - x1 - tmp1 + tmp2
8585
edge.e[1, 0] = y2 - y1 - tmp3 + tmp4
86-
hyaw = phi1 - phi2 + angle1 - angle2
87-
edge.e[2, 0] = pi_2_pi(yaw2 - yaw1 - hyaw)
86+
edge.e[2, 0] = 0
8887

8988
Rt1 = calc_rotational_matrix(tangle1)
9089
Rt2 = calc_rotational_matrix(tangle2)
@@ -137,12 +136,12 @@ def calc_jacobian(edge):
137136
t1 = edge.yaw1 + edge.angle1
138137
A = np.array([[-1.0, 0, edge.d1 * math.sin(t1)],
139138
[0, -1.0, -edge.d1 * math.cos(t1)],
140-
[0, 0, -1.0]])
139+
[0, 0, 0]])
141140

142141
t2 = edge.yaw2 + edge.angle2
143142
B = np.array([[1.0, 0, -edge.d2 * math.sin(t2)],
144143
[0, 1.0, edge.d2 * math.cos(t2)],
145-
[0, 0, 1.0]])
144+
[0, 0, 0]])
146145

147146
return A, B
148147

@@ -169,7 +168,6 @@ def graph_based_slam(x_init, hz):
169168
print("start graph based slam")
170169

171170
zlist = copy.deepcopy(hz)
172-
zlist.insert(1, zlist[0])
173171

174172
x_opt = copy.deepcopy(x_init)
175173
nt = x_opt.shape[1]
@@ -276,20 +274,28 @@ def main():
276274
xDR = np.zeros((STATE_SIZE, 1)) # Dead reckoning
277275

278276
# history
279-
hxTrue = xTrue
280-
hxDR = xTrue
277+
hxTrue = []
278+
hxDR = []
281279
hz = []
282280
dtime = 0.0
283-
281+
init = False
284282
while SIM_TIME >= time:
283+
284+
if not init:
285+
hxTrue = xTrue
286+
hxDR = xTrue
287+
init = True
288+
else:
289+
hxDR = np.hstack((hxDR, xDR))
290+
hxTrue = np.hstack((hxTrue, xTrue))
291+
285292
time += DT
286293
dtime += DT
287294
u = calc_input()
288295

289296
xTrue, z, xDR, ud = observation(xTrue, xDR, u, RFID)
290297

291-
hxDR = np.hstack((hxDR, xDR))
292-
hxTrue = np.hstack((hxTrue, xTrue))
298+
293299
hz.append(z)
294300

295301
if dtime >= show_graph_dtime:

0 commit comments

Comments
 (0)