BA问题归结为一个LS(Least Square)问题:
min
g
(
t
)
=
1
2
∑
<
i
,
j
>
∈
G
f
i
j
⊤
f
i
j
\min g(\mathbf{t}) = \frac{1}{2} \displaystyle \sum_{<i,j> \in G} \mathbf{f}_{ij}^\top \mathbf{f}_{ij}
ming(t)=21<i,j>∈G∑fij⊤fij
令
g
=
Δ
[
⋮
f
i
j
⋮
]
\mathbf{g} \stackrel{\Delta}{=} \begin{bmatrix} \vdots \\ \mathbf{f}_{ij} \\ \vdots \end{bmatrix}
g=Δ
⋮fij⋮
g
\mathbf{g}
g的雅可比矩阵:
J
=
Δ
∂
g
∂
t
=
[
⋯
⋯
⋯
⋯
⋯
⋯
⋯
⋯
⋯
⋯
⋯
⋮
⋮
⋮
⋮
⋮
⋮
⋮
⋮
⋮
⋮
⋮
0
⋯
0
∂
f
i
j
∂
x
i
0
⋯
0
∂
f
i
j
∂
y
j
0
⋯
0
⋮
⋮
⋮
⋮
⋮
⋮
⋮
⋮
⋮
⋮
⋮
⋯
⋯
⋯
⋯
⋯
⋯
⋯
⋯
⋯
⋯
⋯
]
\mathbf{J} \stackrel{\Delta}{=} \frac{\partial \mathbf{g}}{\partial \mathbf{t}} = \begin{bmatrix} \cdots &\cdots &\cdots &\cdots &\cdots &\cdots &\cdots &\cdots &\cdots &\cdots &\cdots \\ \vdots &\vdots &\vdots &\vdots &\vdots &\vdots &\vdots &\vdots &\vdots &\vdots &\vdots \\ \mathbf{0} &\cdots &\mathbf{0} &\frac{\partial \mathbf{f}_{ij}}{\partial \mathbf{x}_i} &\mathbf{0} &\cdots &\mathbf{0} &\frac{\partial \mathbf{f}_{ij}}{\partial \mathbf{y}_j} &\mathbf{0} &\cdots &\mathbf{0} \\ \vdots &\vdots &\vdots &\vdots &\vdots &\vdots &\vdots &\vdots &\vdots &\vdots &\vdots \\ \cdots &\cdots &\cdots &\cdots &\cdots &\cdots &\cdots &\cdots &\cdots &\cdots &\cdots \end{bmatrix}
J=Δ∂t∂g=
⋯⋮0⋮⋯⋯⋮⋯⋮⋯⋯⋮0⋮⋯⋯⋮∂xi∂fij⋮⋯⋯⋮0⋮⋯⋯⋮⋯⋮⋯⋯⋮0⋮⋯⋯⋮∂yj∂fij⋮⋯⋯⋮0⋮⋯⋯⋮⋯⋮⋯⋯⋮0⋮⋯
H
=
Δ
J
⊤
J
\mathbf{H} \stackrel{\Delta}{=}\mathbf{J}^\top \mathbf{J}
H=ΔJ⊤J:
J
i
j
=
Δ
[
0
⋯
0
∂
f
i
j
∂
x
i
0
⋯
0
∂
f
i
j
∂
y
j
0
⋯
0
]
\mathbf{J}_{ij} \stackrel{\Delta}{=} \begin{bmatrix} \mathbf{0} &\cdots &\mathbf{0} &\frac{\partial \mathbf{f}_{ij}}{\partial \mathbf{x}_i} &\mathbf{0} &\cdots &\mathbf{0} &\frac{\partial \mathbf{f}_{ij}}{\partial \mathbf{y}_j} &\mathbf{0} &\cdots &\mathbf{0} \\ \end{bmatrix}
Jij=Δ[0⋯0∂xi∂fij0⋯0∂yj∂fij0⋯0]
H = J ⊤ J = ∑ < i , j > ∈ G J i j ⊤ J i j \mathbf{H} = \mathbf{J}^\top \mathbf{J} = \sum_{<i,j> \in G} \mathbf{J}_{ij}^\top \mathbf{J}_{ij} H=J⊤J=<i,j>∈G∑Jij⊤Jij
J i j ⊤ J i j = [ ⋯ 0 ⋯ 0 ⋯ ⋮ ⋮ ⋮ ⋮ ⋮ ⋯ 0 ⋯ 0 ⋯ ⋯ ( ∂ f i j ∂ x i ) ⊤ ∂ f i j ∂ x i ⋯ ( ∂ f i j ∂ x i ) ⊤ ∂ f i j ∂ y j ⋯ ⋯ 0 ⋯ 0 ⋯ ⋮ ⋮ ⋮ ⋮ ⋮ ⋯ 0 ⋯ 0 ⋯ ⋯ ( ∂ f i j ∂ y j ) ⊤ ∂ f i j ∂ x i ⋯ ( ∂ f i j ∂ y j ) ⊤ ∂ f i j ∂ y j ⋯ ⋯ 0 ⋯ 0 ⋯ ⋮ ⋮ ⋮ ⋮ ⋮ ⋯ 0 ⋯ 0 ⋯ ] \mathbf{J}_{ij}^\top \mathbf{J}_{ij} = \begin{bmatrix} \cdots &\mathbf{0} &\cdots &\mathbf{0} &\cdots \\ \vdots &\vdots &\vdots &\vdots &\vdots \\ \cdots &\mathbf{0} &\cdots &\mathbf{0} &\cdots \\ \cdots &(\frac{\partial \mathbf{f}_{ij}}{\partial \mathbf{x}_i})^\top \frac{\partial \mathbf{f}_{ij}}{\partial \mathbf{x}_i} &\cdots &(\frac{\partial \mathbf{f}_{ij}}{\partial \mathbf{x}_i})^\top \frac{\partial \mathbf{f}_{ij}}{\partial \mathbf{y}_j} &\cdots \\ \cdots &\mathbf{0} &\cdots &\mathbf{0} &\cdots \\ \vdots &\vdots &\vdots &\vdots &\vdots \\ \cdots &\mathbf{0} &\cdots &\mathbf{0} &\cdots \\ \cdots &(\frac{\partial \mathbf{f}_{ij}}{\partial \mathbf{y}_j})^\top \frac{\partial \mathbf{f}_{ij}}{\partial \mathbf{x}_i} &\cdots &(\frac{\partial \mathbf{f}_{ij}}{\partial \mathbf{y}_j})^\top \frac{\partial \mathbf{f}_{ij}}{\partial \mathbf{y}_j} &\cdots \\ \cdots &\mathbf{0} &\cdots &\mathbf{0} &\cdots \\ \vdots &\vdots &\vdots &\vdots &\vdots \\ \cdots &\mathbf{0} &\cdots &\mathbf{0} &\cdots \\ \end{bmatrix} Jij⊤Jij= ⋯⋮⋯⋯⋯⋮⋯⋯⋯⋮⋯0⋮0(∂xi∂fij)⊤∂xi∂fij0⋮0(∂yj∂fij)⊤∂xi∂fij0⋮0⋯⋮⋯⋯⋯⋮⋯⋯⋯⋮⋯0⋮0(∂xi∂fij)⊤∂yj∂fij0⋮0(∂yj∂fij)⊤∂yj∂fij0⋮0⋯⋮⋯⋯⋯⋮⋯⋯⋯⋮⋯
遍历observation edges, 根据edge连接的pose vertex id和landmark vertex id去确定在 H \mathbf{H} H里的位置,然后朝里累加数据. 所以看着很简单就能得到 H \mathbf{H} H。
b
=
J
⊤
g
\mathbf{b} = \mathbf{J}^\top \mathbf{g}
b=J⊤g:
b
=
∑
<
i
,
j
>
∈
G
J
i
j
⊤
f
i
j
\mathbf{b} = \sum_{<i,j> \in G} \mathbf{J}_{ij}^\top \mathbf{f}_{ij}
b=<i,j>∈G∑Jij⊤fij
J i j ⊤ f i j = [ 0 ⋮ 0 ( ∂ f i j ∂ x i ) ⊤ f i j 0 ⋮ 0 ( ∂ f i j ∂ y i ) ⊤ f i j 0 ⋮ 0 ] \mathbf{J}_{ij}^\top \mathbf{f}_{ij} = \begin{bmatrix} \mathbf{0} \\ \vdots \\ \mathbf{0} \\ (\frac{\partial \mathbf{f}_{ij}}{\partial \mathbf{x}_i})^\top \mathbf{f}_{ij} \\ \mathbf{0} \\ \vdots \\ \mathbf{0} \\ (\frac{\partial \mathbf{f}_{ij}}{\partial \mathbf{y}_i})^\top \mathbf{f}_{ij} \\ \mathbf{0} \\ \vdots \\ \mathbf{0} \\ \end{bmatrix} Jij⊤fij= 0⋮0(∂xi∂fij)⊤fij0⋮0(∂yi∂fij)⊤fij0⋮0
这样,同样也是遍历observation edges,到edge连接的pose vertex id和landmark vertex id所标识的 b \mathbf{b} b里的位置上去累加数据,即可,也是很easy。
LS问题的核心是求解如下的线性方程组:
H
Δ
t
=
b
\mathbf{H} \Delta \mathbf{t}= \mathbf{b}
HΔt=b