Vision and inertial positioning
UAT 458 Indoor Autonomous UAS and Navigation Technology
Lesson
By the end of this module you will be able to
- Explain why GNSS fails indoors and sort indoor positioning techniques into motion-measuring and reference-measuring families
- Compute the position error accumulated from accelerometer and gyro biases when the IMU is used alone
- Use the pinhole camera model to compute the range to a fiducial marker and its error, and choose a tag size for the working distance
- Compute speed from optical flow and space reference sightings to reset VIO drift
Why this matters
Outdoors, a drone knows where it is from GNSS almost all the time. Under the steel roof of a large building, satellite signals are too weak to use or bounce off walls and give false positions. A drone flying indoors must find its position some other way, and if it cannot, it cannot hold a hover, cannot follow a route, and may drift into the roof structure within seconds.
This course covers indoor navigation technology in the order of the course description: positioning with vision, infrared, ultra-wideband (UWB), LiDAR and inertial sensors, sensor fusion, mapping, path planning, real-time localization, and the evaluation of accuracy and robustness. The focus is on measurement principles and the mathematics of estimation. Configuring an autopilot to fly without GNSS, holding position, avoiding obstacles and indoor flight-test procedures are covered in modules 1–5 of this course (Indoor Autonomous UAS).
This part of the course (Modules 6 to 10) runs one fictional case through all of them: an exhibition and convention centre in the Bangkok metropolitan area wants to use a drone to inspect the roof trusses, lighting rigs and sprinkler pipes of Hall 3 on nights when no event is running. The hall is 120 m wide and 72 m deep, the underside of the roof trusses is 18 m up, and there are no columns inside the hall. The floor is plain, polished grey concrete. During events it is filled with booths, stages and steel stands whose layout changes every time. The facilities team must choose and evaluate a navigation system that lets the drone inspect close to the trusses with a position error no larger than 0.30 m. All figures in this course are fictional. The Python code can be downloaded from /downloads/uat-458/.
The indoor positioning problem
Localization means knowing where you are and which way you face in a coordinate frame shared with the map and the mission. Siegwart and colleagues (2011) divide the methods of mobile robots into two families, and both apply directly to drones indoors.
- Measure your own motion and add it up (dead reckoning, or odometry): IMU, optical flow, VIO (visual-inertial odometry) and LiDAR odometry. Nothing needs installing in the building and the data are fast and continuous, but small errors in each step accumulate into drift that keeps growing.
- Measure against references at known positions: fiducial markers on the walls, infrared cameras around the space, UWB anchors, or LiDAR matched against a map. Errors do not accumulate, but the references must be visible or reachable by radio, and they must be installed or surveyed first.
Almost every working system uses both families. It is like walking through a dark room counting your steps and touching a wall at a known place now and then to correct the count (Groves, 2013). Counting gives a position at every instant; touching the wall stops the error from piling up until you are lost. How the two are combined is the subject of module 8.
Before choosing any technology, the team must write the navigation requirements as numbers, because “accurate” on its own cannot be compared with anything. Hall 3 has five requirements.
| Requirement | Meaning | Team value (assumed) |
|---|---|---|
| Accuracy | Position error allowed at the 95th percentile | At most 0.30 m near the trusses |
| Update rate | New positions per second | At least 30 Hz into the autopilot |
| Latency | Time from measurement to a usable position | At most 80 ms |
| Coverage | Area and height where the system works | The whole 120 × 72 m hall up to 18 m |
| Robustness | Still works when light, booth layout or signals change | Tested against the list in module 10 |
Inertial sensors and error growth
An IMU (inertial measurement unit) combines gyroscopes, which measure rotation rate, with accelerometers, which measure specific force (acceleration including the effect of gravity). The per-axis error model with scale, bias and noise was covered in UAT 205. Here only one question matters: if the IMU alone is used to compute position, how fast does the error grow?
A strapdown inertial navigation system repeats three steps: integrate rotation rate into attitude, rotate acceleration from the body frame into the world frame and remove gravity, then integrate twice into velocity and position. Woodman (2007) shows how each error type propagates differently.
- Accelerometer bias is integrated twice, so position drifts by , growing with the square of time.
- Gyro bias tilts the attitude estimate by . With a tilt error, a share of gravity leaks into the horizontal axes and is mistaken for acceleration. Integrating twice more gives , growing with the cube of time. Woodman calls this the critical error path in nearly all inertial systems.
- White noise produces random walks that grow much more slowly than bias, so over a few seconds of flight it matters less.
Example 1 How long can the IMU alone carry the drone?
The roof-inspection drone’s IMU has a residual accelerometer bias after calibration of 0.05 m/s² and a residual gyro bias of 0.01°/s (assumed). If every other reference disappears, how large does the position error become, and how long until it exceeds the 0.30 m limit?
import math
# Example 1: position error of IMU-only dead reckoning (assumed MEMS values)
g = 9.81
b_a = 0.05 # accelerometer bias (m/s^2)
b_g = math.radians(0.01) # gyro bias 0.01 deg/s in rad/s
def err_acc(t): # double-integrated accelerometer bias
return 0.5 * b_a * t ** 2
def err_gyro(t): # tilt grows as b_g*t, gravity leaks g*sin(tilt), integrated twice
return g * b_g * t ** 3 / 6
for t in (1, 5, 10, 30, 60):
print(f"t {t:2d} s: accel bias {err_acc(t):7.2f} m, gyro bias {err_gyro(t):6.2f} m")
limit = 0.30 # allowed error near a roof truss (m)
t_acc = math.sqrt(2 * limit / b_a)
t_gyro = (6 * limit / (g * b_g)) ** (1 / 3)
print(f"0.30 m reached after {t_acc:.1f} s (accel) and {t_gyro:.1f} s (gyro)")
t 1 s: accel bias 0.03 m, gyro bias 0.00 m
t 5 s: accel bias 0.62 m, gyro bias 0.04 m
t 10 s: accel bias 2.50 m, gyro bias 0.29 m
t 30 s: accel bias 22.50 m, gyro bias 7.70 m
t 60 s: accel bias 90.00 m, gyro bias 61.64 m
0.30 m reached after 3.5 s (accel) and 10.2 s (gyro)
An accelerometer bias of only 0.05 m/s² (about 5 milli-g) pushes the position past 0.30 m in 3.5 seconds and 22.5 m off in 30 seconds. Gyro bias starts more slowly but grows faster because of the cube: 61.6 m after 60 seconds. The conclusion is that the IMU only bridges short gaps between reference measurements; the system must always receive a correction from another source within a few seconds.
Positioning with fiducial markers
A camera is the lightest and cheapest sensor on a drone. The simplest and most dependable way to localize with vision is a fiducial marker, a black-and-white pattern designed to be detected and decoded unambiguously. A widely used example is AprilTag, whose code Olson (2011) designed so that tag IDs are clearly distinct and detection tolerates oblique views and poor light. Tags can be printed on an ordinary printer. When the true size and mounting position of a tag are known, the camera can compute its own position and heading relative to it.
The calculation rests on the pinhole camera model from UAT 205. A point at depth lands in the image at , so a tag of true size appears pixels long (Hartley & Zisserman, 2004). Inverting gives the range . Real software solves a PnP (perspective-n-point) problem from all four tag corners, which yields range and orientation together, but the relation between image size and range is the same.
Differentiating gives the range error : the error grows with the square of the range. The same tag twice as far away gives four times the range error, and a tag that is too small in the image may not decode at all.
Example 2 How large must the tags on the hall’s perimeter columns be?
The drone’s forward camera has a focal length of 900 px from calibration. The team prints 0.40 m tags, edge detection is good to 0.5 px, and the team rule is that a tag must span at least 40 px to decode reliably (assumed). During inspection the drone can be up to 12 m from a perimeter column.
# Example 2: distance to an AprilTag from its apparent size (pinhole model)
fx = 900.0 # focal length in pixels (assumed, from calibration)
S = 0.40 # printed tag edge length (m)
sigma_px = 0.5 # corner-detection noise on the measured edge length (px)
MIN_PX = 40 # team rule: the tag must span at least 40 px to decode reliably
def tag_px(Z, size=S):
return fx * size / Z
def range_err(Z, size=S): # dZ = Z^2 / (fx * S) * d(px)
return Z ** 2 / (fx * size) * sigma_px
for Z in (2, 5, 9, 12):
s = tag_px(Z)
print(f"Z {Z:2d} m: tag {s:5.1f} px, range error {range_err(Z) * 100:4.1f} cm, {'ok' if s >= MIN_PX else 'too small'}")
Z_need = 12.0
S_need = MIN_PX * Z_need / fx
print(f"tag size for {Z_need:.0f} m: {S_need:.2f} m, range error {range_err(Z_need, S_need) * 100:.1f} cm")
Z 2 m: tag 180.0 px, range error 0.6 cm, ok
Z 5 m: tag 72.0 px, range error 3.5 cm, ok
Z 9 m: tag 40.0 px, range error 11.2 cm, ok
Z 12 m: tag 30.0 px, range error 20.0 cm, too small
tag size for 12 m: 0.53 m, range error 15.0 cm
The 0.40 m tag works to about 9 m, where it spans exactly 40 px with an 11.2 cm range error. At 12 m it spans only 30 px and fails the decoding rule, so the perimeter columns need tags of at least 0.53 m, which give a 15 cm range error at 12 m. The tag on the landing pad, seen from 2 m, can be small and still accurate to millimetres.
The limit of tags is that they give a position only while one is in view. Between tags the drone must rely on a motion-measuring method, so tags serve to reset drift at intervals and to guide precise landing on a charging pad.
Optical flow and VIO
Optical flow is the apparent motion of floor texture in a downward-looking camera, measured as an angular rate (rad/s). After removing the aircraft’s own rotation using the gyro, horizontal speed is approximately , where is the height above the floor from a rangefinder. The ArduPilot documentation has users check both the flow sensor and the rangefinder, and calibrate flow by rocking the stationary airframe and inspecting the logged plots before flight (ArduPilot Dev Team, n.d.), because any height error passes straight into the speed estimate.
VIO (visual-inertial odometry) tracks image features across frames and combines them with the IMU. A single camera knows the shape of the path but not its scale in metres; the IMU supplies the scale and bridges motion blur. VINS-Mono is an open system that uses one camera and an IMU (Qin and colleagues, 2018). VIO needs nothing installed in the building, but it is still a motion-measuring method, so it drifts with distance flown, usually quoted as a percentage of distance.
Example 3 Speed from optical flow and the spacing of reference sightings
The drone flies low at 2.5 m above the floor, the sensor measures a flow of 0.6 rad/s, and the height may be off by 0.25 m. The roof-truss inspection route is 840 m long and uses VIO that drifts by 1% of distance travelled (assumed).
# Example 3: optical flow speed and VIO drift along the truss inspection route
omega, h = 0.6, 2.5 # flow rate (rad/s) after removing rotation, height above floor (m)
print(f"optical flow speed {omega * h:.2f} m/s")
dh = 0.25 # height error (m)
print(f"speed error from height error {omega * dh:.2f} m/s ({dh / h:.0%})")
route = 840.0 # length of one inspection route (m)
drift = 0.01 # VIO drift: 1% of distance travelled (assumed)
allow = 0.30 # allowed position error (m)
print(f"VIO drift over the route: {route * drift:.1f} m")
spacing = allow / drift
print(f"reset every {spacing:.0f} m -> about {math.ceil(route / spacing)} tag sightings per route")
optical flow speed 1.50 m/s
speed error from height error 0.15 m/s (10%)
VIO drift over the route: 8.4 m
reset every 30 m -> about 28 tag sightings per route
A 10% height error gives a 10% speed error. At 18 m under the trusses, optical flow looking down at plain polished concrete has almost no texture to track, so it is useful mainly during take-off and landing near the floor. VIO drifts 8.4 m over one route; to stay within 0.30 m it needs a tag or other reference every 30 m, about 28 sightings per route. This figure is why the team considers references that cover the whole hall, such as the UWB of module 7.
Module lab
Lab: IMU drift and range from AprilTags
- Leave an IMU or flight controller still on a bench for 10 minutes, log the accelerometer, find the bias from the mean, then use the code in Example 1 to compute when the position error would exceed 0.30 m
- Print AprilTags in two sizes, fix them to a wall, and photograph them from 1 to 8 m with a calibrated camera. Measure the true range with a tape and compare the range from the tag-detection software with
- Find the longest range at which the software decodes the tag in every image, and set your group’s own tag-size rule in place of the 40 px rule in Example 2
- Carry a camera with optical flow and a rangefinder over three floors (patterned carpet, plain floor, glossy floor), log the flow quality, and decide which floors are usable
Common mistakes
Watch out
- Believing the IMU can hold position for long, when a small bias exceeds 0.30 m within seconds
- Watching only accelerometer bias and forgetting that gyro bias leaks gravity into the horizontal axes and grows as a cube
- Using one tag size throughout the building, although the error grows with the square of range
- Computing range without calibrating the camera: a wrong focal length scales every range by the same wrong factor
- Using optical flow high above plain or glossy floors, which offer no texture to track
- Letting VIO run for a long time without references and trusting a position that has drifted several metres
Summary
- Indoor positioning has two families: measuring motion (drifts) and measuring against references (does not accumulate); real systems combine them
- Navigation requirements must be numbers: 95th-percentile accuracy, update rate, latency, coverage and robustness
- The IMU alone drifts by from accelerometer bias and from gyro bias, so it only bridges short gaps
- A fiducial marker gives range with error , so the tag size must suit the working range
- Optical flow gives speed ; VIO gives scaled motion but drifts with distance and needs periodic reference resets
Check your understanding
- With an accelerometer bias of 0.02 m/s², how large is the position error after 10 s on the IMU alone?
- Why does the error from gyro bias grow with the cube of time?
- A camera with = 900 px sees a 0.40 m tag spanning 60 px. How far away is the tag?
- If the range to a tag increases from 3 m to 6 m, by what factor does the range error change?
- VIO drifts by 0.5% of distance. To stay within 0.20 m, how often must a reference be seen?
Answers
- m
- Gyro bias makes the tilt error grow linearly with time, so the gravity leaking into the horizontal axes is a false acceleration that grows with time; integrating it twice more gives the cube of time
- m
- It grows four times, because scales with
- Every m
Key formulas
| Position error from accelerometer bias | |
| Position error from gyro bias (gravity leakage) | |
| Tag size in the image and range | |
| Speed from optical flow |
Key references
- Groves, P. D. (2013). Principles of GNSS, inertial, and multisensor integrated navigation systems (2nd ed.). Artech House. link
- Siegwart, R., Nourbakhsh, I. R., & Scaramuzza, D. (2011). Introduction to autonomous mobile robots (2nd ed.). MIT Press. link
- Woodman, O. J. (2007). An introduction to inertial navigation (Technical Report UCAM-CL-TR-696). University of Cambridge, Computer Laboratory. link
- Olson, E. (2011). AprilTag: A robust and flexible visual fiducial system. In 2011 IEEE International Conference on Robotics and Automation (pp. 3400–3407). IEEE. link
- Hartley, R., & Zisserman, A. (2004). Multiple view geometry in computer vision (2nd ed.). Cambridge University Press. link
- ArduPilot Dev Team. Optical flow sensor testing and setup. ArduPilot Copter documentation. link
- Qin, T., Li, P., & Shen, S. (2018). VINS-Mono: A robust and versatile monocular visual-inertial state estimator. IEEE Transactions on Robotics, 34(4), 1004–1020. link
Further reading
Study the assigned knowledge units in advance, review media and take the module quiz
ระบบระบุตำแหน่งภายในอาคาร
IMU ไจโรสโคป แอกเซเลอโรมิเตอร์ และแมกนีโตมิเตอร์
How VIN, VIO and SLAM differ
In class / field
Lab or field practice from worksheets with a safety checklist
Learning evidence: Checked worksheets and quiz results