Skip to the lesson
FixTheRobot Explore Robotics / Guidance, Navigation and Control / M6 Inertial Navigation / M6-T5

Guidance, Navigation and Control · Theory · M6

M6-T5 — Initial Alignment: Levelling and Gyrocompassing

Before the first flight the computer must know which way the vehicle faces. At rest it can find out from gravity and from the rotation of the Earth, and the second is much harder than the first.

  • Lesson 5 of 6
  • Intermediate
  • Module 6: Inertial Navigation
  • Theory
  • About 12 minutes to read

An inertial system starts with the attitude unknown. Roll and pitch are easy: at rest the accelerometers read the reaction to gravity, which points up. Heading is hard: it has to come from the Earth's rotation, a rate of 15°/h that a gyro must measure to better than its own bias. This lesson derives levelling and gyrocompassing, computes the heading error that a gyro bias and noise cause, and shows that on Hopper's pad a tactical gyro is just good enough and a consumer gyro cannot do it at all.

Learning objectives

After this lesson, you should be able to:

  • Compute roll and pitch from the accelerometer outputs at rest and state their error from an accelerometer bias.
  • Compute heading from the horizontal Earth rate measured by the gyros.
  • Derive the heading error caused by an east gyro bias, by noise and by a levelling error.
  • Decide which sensor grades can gyrocompass and how long they must average.

The intuition

UAV M2-T7: Inertial Navigation Systems lists alignment as a step of starting an INS. This lesson shows how it works and what limits it. A multirotor avoids the problem by taking heading from a magnetometer, which the aiding lesson of module 7 treats. A system that must know its heading without help from outside uses the Earth.

Roll and pitch from gravity

At rest the only specific force is the reaction to gravity, 1 g upward. In the body axes it is a vector whose components tell how the body is tilted: the lateral component gives roll, the axial one pitch. The method is a two-line formula, it is accurate to the accelerometer bias divided by g (0.1 mg is 0.0057°), and it needs only a few seconds of averaging. Nothing about it depends on where on the Earth the vehicle is.

Heading from the Earth's rotation

Once the vehicle is level, the gyros measure the Earth's rotation, 15.04°/h, which points north and up. The horizontal part, Ωcos⁡φ\Omega\cos\varphi (11.5°/h at 40° latitude), points to the north. The gyro axes then show where north is: in a level frame the east gyro reads zero and the north gyro reads the full horizontal rate, and heading is the angle whose tangent is the ratio of the two body-axis readings. This is gyrocompassing. It works only if the gyros can resolve a rate of 11.5°/h to a small fraction of itself.

What limits it

An east gyro bias ε\varepsilon is indistinguishable from a small component of Earth rate along east, which is what a heading error would produce, so δψ=arcsin⁡(ε/(Ωcos⁡φ))\delta\psi = \arcsin(\varepsilon/(\Omega\cos\varphi)). A tactical gyro (0.3°/h) gives 1.5°, a navigation gyro (0.01°/h) 0.05°, an industrial one (3°/h) 15°, and a consumer one (20°/h) has a bias larger than the signal, so the gyrocompass gives nothing. The white noise sets a second limit that averaging reduces as the square root of time: the tactical angle random walk gives 0.5° after 5 minutes. A levelling error also leaks in, scaled by the tangent of the latitude.

Gyrocompass heading error against the east gyro biasHeading error in degrees against the logarithm of the east gyro bias in degrees per hour, at latitude 40 degrees. The curve is the arcsine of the bias divided by the horizontal Earth rate of 11.5 degrees per hour. A navigation grade bias of 0.01 gives 0.05 degrees, a tactical 0.3 gives 1.5 degrees, an industrial 3 gives 15 degrees. A consumer bias of 20 degrees per hour exceeds the Earth rate and the curve ends: no gyrocompassing is possible.-2-1012020406080100log10 of the east gyro bias (°/h)heading error (°)navigation 0.01: 0.05°tactical 0.3: 1.5°industrial 3: 15.1°consumer 20: beyond the Earth rate
Heading error from the gyro bias, at latitude 40°. A tactical gyro gives 1.5°, a navigation gyro 0.05°. Beyond the horizontal Earth rate no heading can be found.

Roll and pitch come from gravity and are easy. Heading comes from the Earth rate and needs a gyro bias that is small against 11.5°/h. Gyrocompassing is therefore a navigation-grade or good tactical-grade capability, and every other system takes its heading from outside.

Definitions

Levelling
Finding roll and pitch at rest from the direction of the specific force (the reaction to gravity).
Gyrocompassing
Finding heading at rest from the direction of the Earth rate in the level body axes.
Horizontal Earth rate
Ωh=Ωcos⁡φ\Omega_h = \Omega\cos\varphi: the north component, 11.52°/h at latitude 40°.
Coarse and fine alignment
A fast first estimate (seconds) from the formulas, refined over minutes by a filter that also estimates the gyro biases.
Levelling
ϕ=atan2⁡(−fy,−fz),θ=atan2⁡ ⁣(fx,fy2+fz2)\phi = \operatorname{atan2}(-f_y, -f_z), \qquad \theta = \operatorname{atan2}\!\bigl(f_x, \sqrt{f_y^2 + f_z^2}\bigr)
f is the accelerometer vector in body axes (forward, right, down) at rest, which reads minus gravity in the body frame. The two formulas give roll and pitch whatever the heading.
Gyrocompassing
ψ=atan2⁡(−ωyℓ, ωxℓ),ωℓ=R(ϕ,θ) ωmeas\psi = \operatorname{atan2}(-\omega_y^{\ell},\ \omega_x^{\ell}), \qquad \omega^{\ell} = \mathbf{R}(\phi,\theta)\,\boldsymbol{\omega}_{\mathrm{meas}}
The measured rate is first rotated into the level plane with the roll and pitch from levelling; ωxℓ\omega_x^\ell is then the component toward the heading axis and ωyℓ\omega_y^\ell the component to the right. The heading is the angle between the body axis and the north direction of the Earth rate.
Heading error budget
δψ≈εEΩcos⁡φ+NT Ωcos⁡φ+tan⁡φ  δϕN\delta\psi \approx \dfrac{\varepsilon_E}{\Omega\cos\varphi} + \dfrac{N}{\sqrt{T}\,\Omega\cos\varphi} + \tan\varphi\;\delta\phi_N
Three terms: the gyro bias on the east axis, the angle random walk averaged over T seconds, and the tilt error about the north axis times tan of the latitude. The three are independent and combine in root-sum-square.

Derivation: the heading error terms

Levelling, then the three terms of the heading error.

  1. fb=−Cnbgn=Cnb [0, 0, −g]T\mathbf{f}^b = -\mathbf{C}_n^b\mathbf{g}^n = \mathbf{C}_n^b\,[0,\ 0,\ -g]^{\mathsf{T}}

    At rest the accelerometer reads the reaction to gravity, which is minus gravity (NED, down positive).

  2. fx=−gsin⁡θ,fy=gcos⁡θsin⁡ϕ (sign by axis convention),fz=−gcos⁡θcos⁡ϕf_x = -g\sin\theta, \quad f_y = g\cos\theta\sin\phi\ (\text{sign by axis convention}), \quad f_z = -g\cos\theta\cos\phi

    Write the third column of the direction cosine matrix for a 3-2-1 sequence; the components depend on roll and pitch only, not on the heading.

  3. δθ=bx/g\delta\theta = b_x/g

    An accelerometer bias on the axial axis is indistinguishable from a tilt of that size. For 0.1 mg it is 1.0×10⁻⁴ rad, 0.0057°.

Heading

  1. ωn=[Ωcos⁡φ, 0, −Ωsin⁡φ]T\boldsymbol{\omega}^n = [\Omega\cos\varphi,\ 0,\ -\Omega\sin\varphi]^{\mathsf{T}}

    The Earth rate in the local frame (north, east, down). The east component is zero by definition of the frame.

  2. ωxℓ=Ωcos⁡φcos⁡ψ,ωyℓ=−Ωcos⁡φsin⁡ψ\omega^{\ell}_x = \Omega\cos\varphi\cos\psi, \quad \omega^{\ell}_y = -\Omega\cos\varphi\sin\psi

    Rotate the horizontal part through the heading ψ\psi into the level body axes.

  3. ψ=atan2⁡(−ωyℓ, ωxℓ)\psi = \operatorname{atan2}(-\omega^\ell_y,\ \omega^\ell_x)

    Invert. The vertical component of the Earth rate is not used.

  4. δψ≈εE/(Ωcos⁡φ)\delta\psi \approx \varepsilon_E/(\Omega\cos\varphi)

    A bias εE\varepsilon_E on the east gyro adds to ωyℓ\omega^\ell_y an amount that the formula reads as a change of heading of that size divided by the horizontal rate (its arcsine for large ones).

  5. δψnoise=NT Ωcos⁡φ\delta\psi_{\mathrm{noise}} = \dfrac{N}{\sqrt{T}\,\Omega\cos\varphi}

    Averaging the gyro output for T seconds reduces white noise (angle random walk N) to N/TN/\sqrt{T}; divide by the horizontal rate to get an angle.

  6. δψtilt=tan⁡φ  δϕN\delta\psi_{\mathrm{tilt}} = \tan\varphi\;\delta\phi_N

    A tilt error about the north axis rotates the vertical Earth rate Ωsin⁡φ\Omega\sin\varphi into the east gyro, a spurious Ωsin⁡φ δϕN\Omega\sin\varphi\,\delta\phi_N; divided by Ωcos⁡φ\Omega\cos\varphi this is tan⁡φ δϕN\tan\varphi\,\delta\phi_N.

Gravity gives the level directly, and the accelerometer bias over g is the tilt error. Heading is the ratio of two components of a 15°/h signal, so every gyro error is divided by 11.5°/h: a bias of 0.3°/h costs 1.5°, and an error that is not small against the signal makes the method useless.

A worked example

Hopper on its pad at latitude 40°: roll 0.8°, pitch −0.5°, heading 30°.

  1. Levelling. From noise-free accelerometers the formulas return roll 0.8000° and pitch −0.5000°. A 0.1 mg accelerometer bias in the forward axis gives a pitch error of 0.0057°.
  2. Gyrocompassing. From noise-free gyros the heading is recovered exactly, 30.0000°.
  3. Bias. An east-axis gyro bias gives a heading error of 0.050° (navigation grade, 0.01°/h), 1.49° (tactical, 0.3°/h) and 15.1° (industrial, 3°/h). A consumer gyro with 20°/h exceeds the 11.5°/h horizontal Earth rate and no heading results.
  4. Levelling leak. A 0.5 mg forward accelerometer bias tilts the levelling by 0.0286° and moves the heading by 0.0120°, equal to the tilt component about north (tilt × sin 30°) times tan 40°.
  5. Noise. With an angle random walk of 0.01°/√s the scatter of the heading is 20.0° after 120 s of averaging (the formula gives 16.3°) and 7.35° after 600 s (formula 7.31°). For the data-sheet classes, after 300 s the angle random walk alone gives 5.2° (consumer), 1.7° (industrial), 0.52° (tactical) and 0.034° (navigation).
  6. Reading. A tactical gyro, 0.3°/h with 0.03°/√h, gives about 1.5° bias error and 0.5° noise: adequate for a launch, not for navigation over hours. Hopper's 3 m, 99% landing requirement over a 100 m hop does not need a heading better than a few degrees.
import math

def lcg(seed):
    s = seed
    while True:
        s = (1103515245 * s + 12345) % 2147483648
        yield (s / 2147483648.0 - 0.5) * 3.4641016

D2R = math.pi / 180
G0, Om = 9.81, 7.2921150e-5
lat = 40 * D2R
rnd = lcg(7)

# true attitude of Hopper on the pad: roll 0.8 deg, pitch -0.5 deg, heading 30 deg (NED, body forward-right-down)
phi, theta, psi = 0.8 * D2R, -0.5 * D2R, 30 * D2R
R_bn = g_bn = None
cph, sph, cth, sth, cps, sps = math.cos(phi), math.sin(phi), math.cos(theta), math.sin(theta), math.cos(psi), math.sin(psi)
# body from NED, 3-2-1
Rbn = [[cth * cps, cth * sps, -sth],
       [sph * sth * cps - cph * sps, sph * sth * sps + cph * cps, sph * cth],
       [cph * sth * cps + sph * sps, cph * sth * sps - sph * cps, cph * cth]]
def mv(M, v): return [sum(M[i][j] * v[j] for j in range(3)) for i in range(3)]
f_n = [0.0, 0.0, -G0]                              # at rest the accelerometers sense -g (the pad pushes up): NED z is down
w_n = [Om * math.cos(lat), 0.0, -Om * math.sin(lat)]
f_b = mv(Rbn, f_n); w_b = mv(Rbn, w_n)

def levelling(f):
    r = math.atan2(-f[1], -f[2])
    p = math.atan2(f[0], math.sqrt(f[1] ** 2 + f[2] ** 2))
    return r, p
r, p = levelling(f_b)
print(f'levelling from noise-free accelerometers: roll {r / D2R:.4f} deg, pitch {p / D2R:.4f} deg (true 0.8, -0.5)')

def gyrocompass(f, w):
    r, p = levelling(f)
    cr, sr, cp, sp = math.cos(r), math.sin(r), math.cos(p), math.sin(p)
    # rotate the measured rate into the level frame
    wx = cp * w[0] + sr * sp * w[1] + cr * sp * w[2]
    wy = cr * w[1] - sr * w[2]
    return math.atan2(-wy, wx)
print(f'gyrocompassing from noise-free gyros: heading {gyrocompass(f_b, w_b) / D2R:.4f} deg (true 30)')

# accelerometer bias -> tilt error, east gyro bias -> heading error
ab = 0.1e-3 * G0
print(f'accelerometer bias 0.1 mg in the forward axis -> pitch error {ab / G0 / D2R:.4f} deg')
for name, eps in (('consumer 20 deg/h', 20.0), ('industrial 3 deg/h', 3.0), ('tactical 0.3 deg/h', 0.3), ('navigation 0.01 deg/h', 0.01)):
    ratio = eps / (Om / D2R * 3600 * math.cos(lat))      # an east-axis bias over the horizontal Earth rate
    if ratio >= 1:
        print(f'  gyro bias {name:22s}: the bias exceeds the horizontal Earth rate, no gyrocompassing')
    else:
        print(f'  gyro bias {name:22s}: heading error {math.degrees(math.asin(ratio)):7.3f} deg')

# a tilt about the north axis leaks the vertical Earth rate into the east gyro: heading error = tilt * tan(latitude)
fb_bad = [f_b[0] + 0.5e-3 * G0, f_b[1], f_b[2]]          # a 0.5 mg forward accelerometer bias
dh = gyrocompass(fb_bad, w_b) - psi
print(f'a 0.5 mg forward accelerometer bias tilts the levelling by {levelling(fb_bad)[1] / D2R - p / D2R:.4f} deg and moves the gyrocompass heading by {dh / D2R:.4f} deg (the tilt component about the north axis, tilt x sin(heading), times tan(latitude): {(levelling(fb_bad)[1] - p) / D2R * math.sin(psi) * math.tan(lat):.4f})')

# noise: average the gyros for T seconds and read the heading; compare the scatter with the formula
N = 0.01 * D2R                                       # rad / sqrt(s), the ARW of the Allan example (36 deg/rt-h)
dt = 0.1
def trial(T):
    n = int(T / dt)
    sw = [0.0, 0.0, 0.0]
    for _ in range(n):
        for i in range(3):
            sw[i] += w_b[i] + N / math.sqrt(dt) * next(rnd)
    w = [x / n for x in sw]
    return gyrocompass(f_b, w) - psi
for T in (120.0, 600.0):
    errs = [trial(T) for _ in range(150)]
    sd = math.sqrt(sum(e * e for e in errs) / len(errs)) / D2R
    th_ = N / math.sqrt(T) / (Om * math.cos(lat)) / D2R
    print(f'  noise only, averaging {T:5.0f} s: scatter of the heading {sd:7.3f} deg, formula N / (sqrt(T) Om cos lat) = {th_:7.3f} deg')
print('heading error from angle random walk alone after 300 s of averaging, by grade:')
for name, arw in (('consumer', 0.30), ('industrial', 0.10), ('tactical', 0.03), ('navigation', 0.002)):
    n_ = arw / 60 * D2R                                # deg / rt-h -> rad / rt-s
    print(f'  {name:11s} ARW {arw:5.3f} deg/rt-h: {n_ / math.sqrt(300.0) / (Om * math.cos(lat)) / D2R:8.3f} deg')
levelling from noise-free accelerometers: roll 0.8000 deg, pitch -0.5000 deg (true 0.8, -0.5)
gyrocompassing from noise-free gyros: heading 30.0000 deg (true 30)
accelerometer bias 0.1 mg in the forward axis -> pitch error 0.0057 deg
  gyro bias consumer 20 deg/h     : the bias exceeds the horizontal Earth rate, no gyrocompassing
  gyro bias industrial 3 deg/h    : heading error  15.092 deg
  gyro bias tactical 0.3 deg/h    : heading error   1.492 deg
  gyro bias navigation 0.01 deg/h : heading error   0.050 deg
a 0.5 mg forward accelerometer bias tilts the levelling by 0.0286 deg and moves the gyrocompass heading by 0.0120 deg (the tilt component about the north axis, tilt x sin(heading), times tan(latitude): 0.0120)
  noise only, averaging   120 s: scatter of the heading  19.962 deg, formula N / (sqrt(T) Om cos lat) =  16.342 deg
  noise only, averaging   600 s: scatter of the heading   7.350 deg, formula N / (sqrt(T) Om cos lat) =   7.308 deg
heading error from angle random walk alone after 300 s of averaging, by grade:
  consumer    ARW 0.300 deg/rt-h:    5.168 deg
  industrial  ARW 0.100 deg/rt-h:    1.723 deg
  tactical    ARW 0.030 deg/rt-h:    0.517 deg
  navigation  ARW 0.002 deg/rt-h:    0.034 deg
levelling and gyrocompass are the formulas above; the noise scatter is measured over 150 trials with a deterministic generator and compared with the formula.

In robotics

Alignment is a part of every start-up, and its time and accuracy are part of the vehicle's specification.

  • Aircraft and missiles. Inertial systems on the ground run a few minutes of gyrocompassing (alignment), with the vehicle stationary. Alignment time rises with the demanded heading accuracy, as the formula above says.
  • Alignment in motion. When the vehicle cannot be at rest (a ship, a missile from an aircraft) the filter of module 7 aligns from a velocity or position reference instead, and the heading becomes observable from the motion rather than from the Earth rate.
  • Using a magnetometer. Small vehicles use a magnetometer for heading, which works with any gyro but needs calibration and a magnetically quiet site (see the aiding lesson of module 7).
  • Estimating the gyro bias. A fine-alignment filter treats the east and north gyro biases as states and can estimate the one in the horizontal plane, within the limits of observability: the heading and the east bias are confounded at rest, which is why the formula cannot do better than the bias.
  • High latitude. The horizontal Earth rate falls as cos φ, and at the poles it vanishes: gyrocompassing fails and the error is ε/Ωcos⁡φ\varepsilon/\Omega\cos\varphi growing without limit.

The drift budget in the next lesson uses the alignment errors as starting values. The formulas here also set the heading error that feeds the lateral position channel of M6-T4: INS Error Dynamics and the Schuler Oscillation.

Common misconceptions

“Gyrocompassing works with any gyro, given long enough averaging.”

Averaging reduces noise but not bias. A gyro whose bias is comparable to the horizontal Earth rate cannot give heading however long the record: a consumer gyro with 20°/h cannot gyrocompass at all.

“Heading is found from the accelerometers like roll and pitch.”

Gravity is vertical, and rotating the vehicle about the vertical does not change what the accelerometers read. Heading needs a horizontal reference, the Earth rate or a magnetic field.

“An accelerometer error does not matter for heading.”

It tilts the levelling, and a tilt about the north axis leaks the vertical Earth rate into the east gyro, giving a heading error of the tilt times tan φ. At high latitude this term is large.

“Alignment is a one-off and its error disappears.”

The initial attitude error starts a Schuler oscillation in the position error, with an amplitude proportional to it, and a heading error never decays at all. It stays in the navigation solution until an aiding measurement corrects it.

“At the pole the gyrocompass is most accurate.”

It is least accurate. The horizontal Earth rate is the signal, and it is largest at the equator and zero at the pole.

Key takeaways

  1. At rest the accelerometers read the reaction to gravity, which gives roll and pitch to about the accelerometer bias over g.
  2. Heading comes from the horizontal Earth rate Ωcos⁡φ\Omega\cos\varphi (11.5°/h at 40°), measured by the level gyros.
  3. The heading error is the gyro bias divided by that rate: 0.05° (0.01°/h), 1.5° (0.3°/h), 15° (3°/h), and nothing for 20°/h.
  4. Noise averages down as N/(T Ωcos⁡φ)N/(\sqrt{T}\,\Omega\cos\varphi); bias does not.
  5. A tilt error about north adds tan⁡φ\tan\varphi times the tilt to the heading.
  6. Hopper's landing requirement needs only a few degrees of heading; a tactical gyro gives about 1.5°.

References and further reading

Each source is marked free or paid. Free to read does not mean free to reuse: the course resources page lists every source with its licence.

  • P. D. Groves, Principles of GNSS, Inertial, and Multisensor Integrated Navigation Systems, 2nd edition, Artech House, 2013, chapter 5 on alignment. Paid.
  • D. H. Titterton and J. L. Weston, Strapdown Inertial Navigation Technology, 2nd edition, IET, 2004, the chapter on alignment and calibration. Paid.
  • A. Noureldin, T. B. Karamat and J. Georgy, Fundamentals of Inertial Navigation, Satellite-based Positioning and their Integration, Springer, 2013. Paid.
  • MIT 16.07 Dynamics (OpenCourseWare) , for the kinematics of the rotating Earth. Free; licence CC BY-NC-SA 4.0.

Knowledge check

Three questions. Write an answer, then reveal the explanation. Your answers stay in your browser.

Question 1

A tactical gyro has a bias of 0.3°/h. What heading error does gyrocompassing at latitude 60° give, and how does it compare with latitude 40°?

Explanation

The horizontal Earth rate at 60° is 15.04 × cos 60° = 7.52°/h, so the heading error is asin(0.3/7.52) = 2.29°. At 40° the rate is 11.52°/h and the error is 1.49°. The error rises toward the pole because the signal, the horizontal Earth rate, falls as cos φ while the bias is unchanged: at 60° the same gyro is about 1.5 times worse, and at 85° it would be useless.

Question 2

After 300 s of averaging a navigation-grade gyro with ARW 0.002°/√h gives a heading noise of 0.034°. Why is the same averaging for a consumer gyro, 5.2°, not an answer to the problem?

Explanation

The noise term is only one part. A consumer gyro has a bias of 20°/h, larger than the horizontal Earth rate of 11.5°/h, so the bias term of the error budget is unbounded: no heading can be extracted from a signal smaller than the offset. Averaging reduces noise as 1/√T but leaves the bias untouched, so the 5.2° figure applies to a gyro whose bias had already been removed, which it has not.

Question 3

A forward accelerometer bias of 0.5 mg tilts the levelling by 0.0286°. Why does that change the gyrocompass heading, and by how much for a vehicle heading 30° at latitude 40°?

Explanation

A tilt rotates the vertical Earth rate (Ω sin φ) into the horizontal gyros. The part of the tilt about the north axis puts a spurious rate Ω sin φ × tilt on the east gyro, which the formula reads as a heading error of tan φ × tilt_N. For heading 30° the north component of a tilt about the body right axis is sin 30° = 0.5, so the heading error is 0.0286° × 0.5 × tan 40° = 0.012°, as computed.

What’s next

Next lesson

M6-T6 — An Inertial Drift Budget

Predict position error against time from each sensor error term, and choose a sensor grade for a mission time and an accuracy.

Nothing below is required to finish this lesson.

Other courses on this site treat neighbouring topics from their own angle:

This course leaves the following to the pages that already teach them: