Skip to content

Commit 8163031

Browse files
committed
keep coding
1 parent 6e68ec9 commit 8163031

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

SLAM/GraphBasedSLAM/graph_based_slam.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Qsim = np.diag([0.0, math.radians(0.0)])**2
1818
Rsim = np.diag([0.0, math.radians(00.0)])**2
1919

20-
DT = 1.0 # time tick [s]
20+
DT = 5.0 # time tick [s]
2121
SIM_TIME = 20.0 # simulation time [s]
2222
MAX_RANGE = 20.0 # maximum observation range
2323
STATE_SIZE = 3 # State size [x,y,yaw]
@@ -80,13 +80,13 @@ def calc_edge(x1, y1, yaw1, x2, y2, yaw2, d1,
8080
edge.e[1, 0] = y2 - y1 - tmp3 + tmp4
8181
edge.e[2, 0] = pi_2_pi(yaw2 - yaw1 - phi1 + phi2)
8282

83-
sig_t = cal_observation_sigma(d1)
84-
sig_td = cal_observation_sigma(d2)
83+
Rt1 = calc_rotational_matrix(tangle1)
84+
Rt2 = calc_rotational_matrix(tangle2)
8585

86-
Rt = calc_rotational_matrix(tangle1)
87-
Rtd = calc_rotational_matrix(tangle2)
86+
sig1 = cal_observation_sigma(d1)
87+
sig2 = cal_observation_sigma(d2)
8888

89-
edge.omega = np.linalg.inv(Rt * sig_t * Rt.T + Rtd * sig_td * Rtd.T)
89+
edge.omega = np.linalg.inv(Rt1 * sig1 * Rt1.T + Rt2 * sig2 * Rt2.T)
9090
edge.d1, edge.d2 = d1, d2
9191
edge.yaw1, edge.yaw2 = yaw1, yaw2
9292
edge.angle1, edge.angle2 = angle1, angle2
@@ -98,6 +98,7 @@ def calc_edge(x1, y1, yaw1, x2, y2, yaw2, d1,
9898
def calc_edges(xlist, zlist):
9999

100100
edges = []
101+
cost = 0.0
101102
zids = list(itertools.combinations(range(len(zlist)), 2))
102103

103104
for (t1, t2) in zids:
@@ -116,7 +117,9 @@ def calc_edges(xlist, zlist):
116117
angle1, phi1, d2, angle2, phi2, t1, t2)
117118

118119
edges.append(edge)
120+
cost += (edge.e.T * edge.omega * edge.e)[0, 0]
119121

122+
print("cost:", cost)
120123
return edges
121124

122125

@@ -169,7 +172,7 @@ def graph_based_slam(x_init, hz):
169172
H, b = fill_H_and_b(H, b, edge)
170173

171174
# to fix origin
172-
H[0:STATE_SIZE, 0:STATE_SIZE] += np.identity(STATE_SIZE)
175+
H[0:STATE_SIZE, 0:STATE_SIZE] += np.identity(STATE_SIZE) * 1000.0
173176

174177
dx = - np.linalg.inv(H).dot(b)
175178

0 commit comments

Comments
 (0)