VINS-Mono-VIO initialization (6: Adjust the gravity direction based on known gravity)

You can find the magnitude of gravity by looking up the table, assuming it is 9.81. We take out the direction of gravity and set the magnitude directly to 9.81.
The purpose of this adjustment is that the known quantities in the equations solved in the previous section also include the error of gravity, and the error needs to be adjusted in this way.

The pictures in the paper are as follows

Let’s adjust the direction of gravity

g

^

?

\vec{\hat{g}}

g^?
?
We must be moving on a sphere. We take the starting point of the previously calculated vector as the center of the circle, 9.81 as the radius, and take two vectors that are orthogonal to the tangent plane of the sphere.

b

1

?

,

b

2

?

\vec{b_{1}},\vec{b_{2}}

b1?
?,b2?
?, the multiplication of these two vectors is the direction of gravity, so that the direction of gravity can be adjusted. The three quantities must be perpendicular to each other.
The adjustment formula is, adjust

w

1

,

w

2

w_{1},w_{2}

The size of w1?,w2? can adjust the gravity direction.

g

=

g

?

g

?

+

w

1

b

1

?

+

w

2

b

2

?

g=||g||·\vec{g} + w_{1}\vec{b_{1}} + w_{2}\vec{b_{2}}

g=∣∣g∣∣?g
? + w1?b1?
? + w2?b2?
?
Then we still use the same solution method as the previous section to superimpose matrices, but this time in the code

g

g

g becomes

B

?

W

B·W

B?W instead,

W

2

×

1

W∈2×1

W∈2×1 refers to the weight change,

B

3

×

2

B∈3×2

B∈3×2 refers to two vertical vectors

You need to first find two vertical vectors and then repeat the operation in the previous section for multiplication. However, here is an iterative operation to solve. The operation in the previous section is actually equivalent to providing an initial value.

Matrix multiplication in the code is actually equivalent to dot multiplication

a

?

?

t

e

m

p

?

=

a

?

t

e

m

p

?

c

o

s

θ

\vec{a}·\vec{temp}=||a||·||temp||·cosθ

a
?temp
?=∣∣a∣∣?∣∣temp∣∣?cosθ, both modules are 1, temp is 1 0 0 or 0 0 1 , here

a

?

\vec{a}

a
is the result of gravity normalization, then the result of these two point products is

c

o

s

θ

cosθ

cosθ

a.transport*temp=cosθ

Then the vector

a

?

\vec{a}

a
multiply this

c

o

s

θ

cosθ

cosθ obtains the length of vector a, this

a

?

\vec{a}

a
is parallel to

g

?

\vec{g}

g
?, the same as the direction of gravity


reuse

t

e

m

p

?

\vec{temp}

temp
? Subtract

a

?

\vec{a}

a
can be obtained perpendicular to

a

?

\vec{a}

a
vector of
According to this schematic diagram, we can obtain the

a

?

\vec{a}

a
It is a vertical vector. After subtracting it, use normalized() to turn it into a unit vector.
then put

a

?

×

b

?

\vec{a}×\vec{b}

a
×b
The third vertical vector is obtained.
Personal understanding: In fact, the vector of this tangent plane can be in any direction. After all, any orthogonal vector rotating around the gravity vector is consistent. This temp vector is just a temporary vector to fix one of the planes. Find Just the corresponding vector

The coefficient in the code is divided by 100, and the result is also divided by 100 because if the coefficient is divided by 100, the result will be amplified 100 times to meet the requirements, so the result must also be divided by 100. This is to amplify the data for the stability of the numerical solution.