前言
ORB是视觉slam算法,这里利用ORB提取到的特征点用于EKF,本实验模型为车载RGBD相机
1. 运动方程
与里程计模型相同,但是区别于传统的平面机器人姿态估计,状态向量中存储的landmark是三维的,即:
s
t
a
t
e
_
v
e
c
t
o
r
=
[
x
y
θ
L
i
w
o
r
l
d
]
state\_vector = \begin{bmatrix} x \\ y \\ \theta \\ L^{world}_i \end{bmatrix}
state_vector=⎣⎢⎢⎡xyθLiworld⎦⎥⎥⎤
其中:
L
i
w
o
r
l
d
=
[
L
x
w
o
r
l
d
L
y
w
o
r
l
d
L
z
w
o
r
l
d
]
L^{world}_i = \begin{bmatrix} L^{world}_x \\ L^{world}_y \\ L^{world}_z \end{bmatrix}
Liworld=⎣⎡LxworldLyworldLzworld⎦⎤
所以协方差矩阵的维度:
s
i
z
e
(
P
)
=
3
+
n
u
m
l
a
n
d
m
a
r
k
∗
3
,
3
+
n
u
m
l
a
n
d
m
a
r
k
∗
3
size(P) = 3 + numlandmark * 3 ,3 + numlandmark*3
size(P)=3+numlandmark∗3,3+numlandmark∗3
2. 观测方程(observation function)
状态向量
s
t
a
t
e
_
v
e
c
t
o
r
state\_vector
state_vector中存储是地标的世界坐标和相机的世界坐标与姿态
那么引入两个算式:
1)landmark由世界坐标到相机坐标:
r
i
=
[
x
y
0
]
r_i = \begin{bmatrix} x \\ y \\ 0 \end{bmatrix}
ri=⎣⎡xy0⎦⎤
R = [ s i n ( θ ) − c o s ( θ ) 0 0 0 − 1 c o s ( θ ) s i n ( θ ) 0 ] R = \begin{bmatrix} sin(\theta) & -cos(\theta) & 0 \\ 0 & 0 & -1 \\ cos(\theta) & sin(\theta) & 0 \end{bmatrix} R=⎣⎡sin(θ)0cos(θ)−cos(θ)0sin(θ)0−10⎦⎤
L i c a m e r a = R ( L i w o r l d − r i ) L^{camera}_i = R(L^{world}_i - r_i) Licamera=R(Liworld−ri)
2) 由相机坐标到像素坐标
u
=
c
x
+
f
x
L
x
c
a
m
e
r
a
/
L
z
c
a
m
e
r
a
u = c_x + f_xL^{camera}_x/L^{camera}_z
u=cx+fxLxcamera/Lzcamera
v
=
c
y
+
f
y
L
y
c
a
m
e
r
a
/
L
z
c
a
m
e
r
a
v = c_y + f_yL^{camera}_y/L^{camera}_z
v=cy+fyLycamera/Lzcamera
将上述两个算式组合就可以得到观测方程:
u
=
c
x
+
f
x
(
s
i
n
(
θ
)
(
l
x
k
−
x
)
−
c
o
s
(
θ
)
(
l
y
k
−
y
)
)
c
o
s
(
θ
)
(
l
x
k
−
x
)
+
s
i
n
(
θ
)
(
l
y
k
−
y
)
u = c_x + \frac{f_x(sin(\theta)(l_x^k - x) - cos(\theta)(l_y^k - y))}{cos(\theta)(l_x^k - x) + sin(\theta)(l_y^k - y)}
u=cx+cos(θ)(lxk−x)+sin(θ)(lyk−y)fx(sin(θ)(lxk−x)−cos(θ)(lyk−y))
v = c y − l z k f y c o s ( θ ) ( l x k − x ) + s i n ( θ ) ( l y k − y ) v = c_y - \frac{l_z^kf_y}{cos(\theta)(l_x^k - x) + sin(\theta)(l_y^k - y)} v=cy−cos(θ)(lxk−x)+sin(θ)(lyk−y)lzkfy
我们认为观测为像素坐标
3. 逆观测方程 (invers observation function)
2.中已经讨论过观测方程,由
L
x
w
o
r
l
d
,
L
y
w
o
r
l
d
,
L
z
w
o
r
l
d
L^{world}_x,L^{world}_y,L^{world}_z
Lxworld,Lyworld,Lzworld得到像素坐标
u
,
v
u,v
u,v,那么所谓的逆运动方程就是反过来:由
u
,
v
+
d
u,v + d
u,v+d(d
表示深度,其实就等于
L
z
w
o
r
l
d
L^{world}_z
Lzworld),计算
L
x
w
o
r
l
d
,
L
y
w
o
r
l
d
L^{world}_x,L^{world}_y
Lxworld,Lyworld,总之:
l x k = d c o s ( θ ) + ( u − c x ) d s i n ( θ ) f x + x l_x^k = dcos(\theta) + \frac{(u - c_x)dsin(\theta)}{f_x} + x lxk=dcos(θ)+fx(u−cx)dsin(θ)+x
l k y = d s i n ( θ ) − ( u − c x ) d c o s ( θ ) f x + y l^y_k = dsin(\theta) - \frac{(u - c_x)dcos(\theta)}{f_x} + y lky=dsin(θ)−fx(u−cx)dcos(θ)+y
l k z = − ( v − c y ) d f y l^z_k = -\frac{(v - c_y)d}{f_y} lkz=−fy(v−cy)d
3. 雅各比矩阵H
3.1 observation function Jacob to pose
d = c o s ( θ ) ( l x k − x ) + s i n ( θ ) ( l y k − y ) d = cos(\theta)(l_x^k - x) + sin(\theta)(l_y^k - y) d=cos(θ)(lxk−x)+sin(θ)(lyk−y)
∂ d ∂ x = − c o s ( θ ) \frac{\partial d}{\partial x} = -cos(\theta) ∂x∂d=−cos(θ)
∂ d ∂ y = − s i n ( θ ) \frac{\partial d}{\partial y} = -sin(\theta) ∂y∂d=−sin(θ)
∂ d ∂ θ = − s i n ( θ ) ( l x k − x ) + c o s ( θ ) ( l y k − y ) \frac{\partial d}{\partial \theta} = -sin(\theta)(l_x^k - x) + cos(\theta)(l_y^k - y) ∂θ∂d=−sin(θ)(lxk−x)+cos(θ)(lyk−y)
H p o s e = [ ∂ u ∂ x ∂ u ∂ y ∂ u ∂ θ ∂ v ∂ x ∂ v ∂ y ∂ v ∂ θ ] H_{pose} = \begin{bmatrix} \frac{\partial u}{\partial x} &\frac{\partial u}{\partial y} & \frac{\partial u}{\partial \theta} \\ \frac{\partial v}{\partial x} &\frac{\partial v}{\partial y} & \frac{\partial v}{\partial \theta} \end{bmatrix} Hpose=[∂x∂u∂x∂v∂y∂u∂y∂v∂θ∂u∂θ∂v]
那么有:
H p o s e = [ f x ( l y k − y ) ( c o s ( θ ) ( l x k − x ) + s i n ( θ ) ( l y k − y ) ) 2 − f x ( l x k − x ) ( c o s ( θ ) ( l x k − x ) + s i n ( θ ) ( l y k − y ) ) 2 − f x ( ( l y k − y ) 2 + ( l x k − x ) 2 ) ( c o s ( θ ) ( l x k − x ) + s i n ( θ ) ( l y k − y ) ) 2 c o s ( θ ) f y l z k ( c o s ( θ ) ( l x k − x ) + s i n ( θ ) ( l y k − y ) ) 2 s i n ( θ ) f y l z k ( c o s ( θ ) ( l x k − x ) + s i n ( θ ) ( l y k − y ) ) 2 − f y l z k ( − s i n ( θ ) ( l x k − x ) + c o s ( θ ) ( l y k − y ) ) ( c o s ( θ ) ( l x k − x ) + s i n ( θ ) ( l y k − y ) ) 2 ] H_{pose} = \begin{bmatrix} \frac{f_x(l_y^k - y)}{(cos(\theta)(l_x^k - x) + sin(\theta)(l_y^k - y))^2} &\frac{-f_x(l_x^k - x)}{(cos(\theta)(l_x^k - x) + sin(\theta)(l_y^k - y))^2} & \frac{-f_x((l_y^k - y)^2 + (l_x^k - x)^2)}{(cos(\theta)(l_x^k - x) + sin(\theta)(l_y^k - y))^2} \\ \frac{cos(\theta)f_yl_z^k}{(cos(\theta)(l_x^k - x) + sin(\theta)(l_y^k - y))^2} & \frac{sin(\theta)f_yl_z^k}{(cos(\theta)(l_x^k - x) + sin(\theta)(l_y^k - y))^2} & -\frac{f_yl_z^k(-sin(\theta)(l_x^k - x) + cos(\theta)(l_y^k - y))}{(cos(\theta)(l_x^k - x) + sin(\theta)(l_y^k - y))^2} \end{bmatrix} Hpose=⎣⎡(cos(θ)(lxk−x)+sin(θ)(lyk−y))2fx(lyk−y)(cos(θ)(lxk−x)+sin(θ)(lyk−y))2cos(θ)fylzk(cos(θ)(lxk−x)+sin(θ)(lyk−y))2−fx(lxk−x)(cos(θ)(lxk−x)+sin(θ)(lyk−y))2sin(θ)fylzk(cos(θ)(lxk−x)+sin(θ)(lyk−y))2−fx((lyk−y)2+(lxk−x)2)−(cos(θ)(lxk−x)+sin(θ)(lyk−y))2fylzk(−sin(θ)(lxk−x)+cos(θ)(lyk−y))⎦⎤
H p o s e H_{pose} Hpose搞错了,每一项都要加上一个负号
3.2 observation function Jacob to landmark
d = c o s ( θ ) ( l x k − x ) + s i n ( θ ) ( l y k − y ) d = cos(\theta)(l_x^k - x) + sin(\theta)(l_y^k - y) d=cos(θ)(lxk−x)+sin(θ)(lyk−y)
∂ d ∂ l x k = c o s ( θ ) \frac{\partial d}{\partial l_x^k} = cos(\theta) ∂lxk∂d=cos(θ)
∂ d ∂ l y k = s i n ( θ ) \frac{\partial d}{\partial l_y^k} = sin(\theta) ∂lyk∂d=sin(θ)
H m a p = [ ∂ u ∂ l x k ∂ u ∂ l y k ∂ u ∂ l z k ∂ v ∂ l x k ∂ v ∂ l y k ∂ v ∂ l z k ] H_{map} = \begin{bmatrix} \frac{\partial u}{\partial l_x^k} &\frac{\partial u}{\partial l_y^k} & \frac{\partial u}{\partial l_z^k} \\ \frac{\partial v}{\partial l_x^k} &\frac{\partial v}{\partial l_y^k} & \frac{\partial v}{\partial l_z^k} \end{bmatrix} Hmap=[∂lxk∂u∂lxk∂v∂lyk∂u∂lyk∂v∂lzk∂u∂lzk∂v]
那么有:
H m a p = [ − f x ( l y k − y ) c o s ( θ ) ( l x k − x ) + s i n ( θ ) ( l y k − y ) f x ( l x k − x ) c o s ( θ ) ( l x k − x ) + s i n ( θ ) ( l y k − y ) 0 − l z k f y c o s ( θ ) ( c o s ( θ ) ( l x k − x ) + s i n ( θ ) ( l y k − y ) ) 2 − l z k f y s i n ( θ ) ( c o s ( θ ) ( l x k − x ) + s i n ( θ ) ( l y k − y ) ) 2 f y c o s ( θ ) ( l x k − x ) + s i n ( θ ) ( l y k − y ) ] H_{map} = \begin{bmatrix} -\frac{f_x(l_y^k - y)}{cos(\theta)(l_x^k - x) + sin(\theta)(l_y^k - y)} &\frac{f_x(l_x^k - x)}{cos(\theta)(l_x^k - x) + sin(\theta)(l_y^k - y)} & 0 \\ -\frac{l_z^kf_ycos(\theta)}{(cos(\theta)(l_x^k - x) + sin(\theta)(l_y^k - y))^2} & -\frac{l_z^kf_ysin(\theta)}{(cos(\theta)(l_x^k - x) + sin(\theta)(l_y^k - y))^2} & \frac{f_y}{cos(\theta)(l_x^k - x) + sin(\theta)(l_y^k - y)}\end{bmatrix} Hmap=⎣⎡−cos(θ)(lxk−x)+sin(θ)(lyk−y)fx(lyk−y)−(cos(θ)(lxk−x)+sin(θ)(lyk−y))2lzkfycos(θ)cos(θ)(lxk−x)+sin(θ)(lyk−y)fx(lxk−x)−(cos(θ)(lxk−x)+sin(θ)(lyk−y))2lzkfysin(θ)0cos(θ)(lxk−x)+sin(θ)(lyk−y)fy⎦⎤
H m a p H_{map} Hmap搞错了,每一项都要加上一个负号
3.3 inverse observation function Jacob to pose
G p o s e = [ 1 0 − d s i n ( θ ) + ( u − c x ) d c o s ( θ ) f x 0 1 d c o s ( θ ) + ( u − c x ) d s i n ( θ ) f x 0 0 0 ] G_{pose} = \begin{bmatrix} 1 &0 & -dsin(\theta) + \frac{(u - c_x)dcos(\theta)}{f_x} \\ 0 & 1 & dcos(\theta) + \frac{(u - c_x)dsin(\theta)}{f_x} \\ 0 & 0 & 0\end{bmatrix} Gpose=⎣⎢⎡100010−dsin(θ)+fx(u−cx)dcos(θ)dcos(θ)+fx(u−cx)dsin(θ)0⎦⎥⎤
3.4 inverse observation function Jacob to landmark
G m a p = [ d s i n ( θ ) f x 0 − d c o s ( θ ) f x 0 0 − d f y ] G_{map} = \begin{bmatrix} \frac{dsin(\theta)}{f_x} & 0 \\ -\frac{dcos(\theta)}{f_x} & 0 \\ 0 & -\frac{d}{f_y} \end{bmatrix} Gmap=⎣⎢⎡fxdsin(θ)−fxdcos(θ)000−fyd⎦⎥⎤