Right now I'm trying to implement a pose graph for a slam algorithm.
In order to this I've seen some videos about it and found a example calculation which I now wanted to expand on x, y, theta
.
The video I've seen was
https://www.youtube.com/watch?v=uHbRKvD8TWg&t=3273s
Luckily I was able to implement his example in python:
import numpy as np
x1 = 0
x2 = 0
z = 1
omega = np.array([2])
e = np.array([z-(x2-x1)]) # 1-(0-0) = 1
J = np.array([1, -1])
b = np.transpose(e)*omega*J
H = np.add(np.array([[1], [-1]])*omega*J, np.array([[1, 0], [0, 0]]))
print(H)
xdelta = -np.linalg.inv(H).dot(b)
print(xdelta)
Furthermore I was able to implement a second dimension with a satisfying response:
import numpy as np
x1 = np.array([0,0])
x2 = np.array([0,0])
z = np.array([0,1])
omega = np.array([[2,2],[2,2]])
e = np.array(z-(x2-x1))
J = np.array([[1,1], [-1, -1]])
b = e.T*omega*J
print(b)
H = np.add(J.T*omega*J, np.array([[1, 0], [0, 0]]))
print(H)
xdelta = -np.linalg.inv(H).dot(b)
print(xdelta)
But when I was trying to add the theta to it, I had no success:
import numpy as np
x1 = np.array([0,0,0])
x2 = np.array([0,0,0])
z = np.array([0,1,0])
e = np.array(z-(x2-x1))
J = np.array([[1,1,1], [-1, -1,-1]])
b = e.T*J
print(J.T)
print(J)
H = np.add(J.dot(J.T), np.array([[1, 0], [0, 0]]))
print(H)
xdelta = -np.linalg.inv(H).dot(b)
print(xdelta)
Now I've wanted to ask for an implementation on this examples.