Skip to content

Commit ea8f35a

Browse files
committed
it works but R,t update method is not good...
1 parent fd4923f commit ea8f35a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

SLAM/iterative_closest_point/iterative_closest_point.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ def ICP_matching(pdata, data):
102102

103103
error = nearest_neighbor_assosiation(pdata, data)
104104
Rt, Tt = SVD_motion_estimation(pdata, data)
105-
# print(count)
106-
# print(error)
105+
print(error)
107106

108107
data = (Rt * data) + Tt
109108
R = R * Rt
@@ -113,6 +112,8 @@ def ICP_matching(pdata, data):
113112
preError = error
114113

115114
if dError <= EPS:
115+
print("Converge", dError)
116+
plt.plot(data[0, :], data[1, :], "*k")
116117
break
117118
elif maxIter <= count:
118119
break
@@ -140,7 +141,7 @@ def SVD_motion_estimation(pdata, data):
140141
pshift = np.matrix(pdata - pm)
141142
cshift = np.matrix(data - cm)
142143

143-
W = pshift * cshift.T
144+
W = cshift * pshift.T
144145
u, s, vh = np.linalg.svd(W)
145146

146147
R = (u * vh).T
@@ -174,12 +175,12 @@ def main():
174175
# print(data)
175176

176177
R, T = ICP_matching(pdata, data)
177-
print(motion)
178-
print(R)
179-
print(T)
178+
179+
fdata = (R * data) + T
180180

181181
plt.plot(px, py, ".b")
182182
plt.plot(cx, cy, ".r")
183+
plt.plot(fdata[0, :], fdata[1, :], "xk")
183184
plt.plot(0.0, 0.0, "xr")
184185
plt.axis("equal")
185186
plt.show()

0 commit comments

Comments
 (0)