IMU Basics
IMU Basics
(IMU) Basics
IMU (Inertial Measurement Unit)
𝐹𝑘
Accelerometer measures
𝑚
𝑚𝑎𝑎𝑐𝑐𝑙
𝐹𝑘 = 𝑚𝑔
𝐹𝑘
𝐴𝑚𝑒𝑎𝑠𝑢𝑟𝑒𝑑 = = 𝑔 Accelerometer output under
𝑚 rest is non-zero. It measures g
𝑚𝑎𝑎𝑐𝑐𝑙 = 𝐹𝑘 − 𝑚𝑔
𝐹𝑘 Accelerometer output under motion
𝐴𝑚𝑒𝑎𝑠𝑢𝑟𝑒𝑑 = = 𝑔 + 𝑎𝑎𝑐𝑐𝑙
𝑚
Zero
G = 9.8 m/s2
Measuring linear motion (1D)
𝐴𝑚𝑒𝑎𝑠𝑢𝑟𝑒𝑑 = 𝑔 + 𝑎𝑎𝑐𝑐𝑙
𝑑2𝑥
= Ameas − g + n Hardware noise
𝑑𝑡 2
𝑑𝑥
= න(𝐴 − 𝑔 + 𝑛) 𝑑𝑡 = න 𝐴 − 𝑔 𝑑𝑡 + න 𝑛 𝑑𝑡
𝑑𝑡
𝑡 𝑡
𝑥 = ඵ 𝐴 − 𝑔 𝑑𝑡 + ඵ 𝑛 𝑑𝑡 Error accumulates dramatically with time
0 0
Subtraction of gravity non-trivial in 2D or 3D
Subtraction of gravity in 2D
𝑎𝑥
g
Subtraction of gravity in 2D
1D equation → 𝐴𝑚𝑒𝑎𝑠 = 𝑎𝑎𝑐𝑐𝑙 + 𝑔
𝐴𝑥 = 𝑎𝑥 + 𝑔𝑠𝑖𝑛𝜃
g 𝐴𝑦 = 𝑎𝑦 + 𝑔𝑐𝑜𝑠𝜃
Inaccurate orientation will not eliminate gravity, resulting in errors (which accumulate over time)
An interesting idea
2D equations (arbitrary rotation of phone)
𝐴𝑥 = 𝑎𝑥 + 𝑔𝑠𝑖𝑛𝜃
𝐴𝑦 = 𝑎𝑦 + 𝑔𝑐𝑜𝑠𝜃
𝐴𝑥 = 𝑔𝑠𝑖𝑛𝜃
𝑔
𝑠𝑖𝑛𝜃 =
𝐴𝑥
𝑀𝑦 = 𝑀
𝑀𝑥 = 0
x
Measures magnetic north (2D example)
Magnetic north
y Suppose, phone rotates in 2D by an angle
𝑀𝑦 = 𝑀𝑐𝑜𝑠𝜃
x 𝑀𝑥 = 𝑀 𝑠𝑖𝑛𝜃
Up
East
Z
X
North
18
Consider a phone in random orientation
Up
East
X Z
North
19
Rotation Matrix
𝑉
Up
East
In global frame
X Z
In local frame
Y
𝑥𝑙 ⋯ 𝑥𝑔
North Rotation
𝑦𝑙 = ⋮ ⋱ ⋮ 𝑦𝑔
𝑧𝑙 Matrix R 𝑧𝑔
𝑎𝑥 ⋯ 0 𝑚𝑥 ⋯ 0
Rotation
𝑎𝑦 = ⋮ ⋱ ⋮ Rotation
𝑚𝑦 = ⋮ ⋱ ⋮
0 𝑀
𝑎𝑧 Matrix R 𝑚𝑧 Matrix R
−𝑔 0
Yes, these 9 unknowns are all not independent (rotation matrix satisfies special properties)
• It does not change length of a vector
• Columns are orthogonal unit vectors
Accelerometer and Magnetometer can be used to determine the rotation matrix (3D orientation)
Decomposing the rotation matrix
yaw
pitch
Z
X
roll Y
𝑎𝑥 cos(𝑝𝑖𝑡𝑐ℎ) 0 −sin(𝑝𝑖𝑡𝑐ℎ) 1 0 0 0
𝑎𝑦 = 0 1 0 0 cos(𝑟𝑜𝑙𝑙) sin(𝑟𝑜𝑙𝑙) 0
𝑎𝑧 sin(𝑝𝑖𝑡𝑐ℎ) 0 cos(𝑝𝑖𝑡𝑐ℎ) 0 −sin(𝑟𝑜𝑙𝑙) 𝑐𝑜𝑠(𝑟𝑜𝑙𝑙) −𝑔
yaw, pitch, roll together determine the rotation matrix (3D orientation) of a system
Gyroscope
1D example
• Measures angular velocity
𝑔𝑦𝑟𝑜 = 𝜔
𝑑𝜃
= 𝜔
𝑑𝑡
𝑑𝜃
= 𝜔 + 𝑛𝑜𝑖𝑠𝑒
𝑑𝑡
𝑡 𝑡 Error
𝜃 = න 𝜔 . 𝑑𝑡 + න 𝑛𝑜𝑖𝑠𝑒 . 𝑑𝑡
0 0
Time
𝜔𝑥
3D angular velocity 𝜔𝑦
𝜔𝑧
Gyroscope Measurements
Time
Error
Time