0% found this document useful (0 votes)
256 views

IMU Basics

Here are the key points about estimating orientation from an accelerometer: - The accelerometer measures acceleration due to gravity and linear motion. When stationary, it measures just gravity. - Gravity points downwards, so the accelerometer output gives the direction of gravity in the device's local frame. - We know gravity is always pointing straight down in the global frame. - By comparing the accelerometer output (direction of gravity in local frame) to the known direction of gravity in global frame, we can calculate the rotation matrix that transforms between the frames. - The rotation matrix relates the orientation of the local frame to the global frame. It can be decomposed into yaw, pitch and roll angles to represent the

Uploaded by

Tuhin Rahariya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
256 views

IMU Basics

Here are the key points about estimating orientation from an accelerometer: - The accelerometer measures acceleration due to gravity and linear motion. When stationary, it measures just gravity. - Gravity points downwards, so the accelerometer output gives the direction of gravity in the device's local frame. - We know gravity is always pointing straight down in the global frame. - By comparing the accelerometer output (direction of gravity in local frame) to the known direction of gravity in global frame, we can calculate the rotation matrix that transforms between the frames. - The rotation matrix relates the orientation of the local frame to the global frame. It can be decomposed into yaw, pitch and roll angles to represent the

Uploaded by

Tuhin Rahariya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 36

Inertial Measurement Unit

(IMU) Basics
IMU (Inertial Measurement Unit)

Accelerometer Gyroscope Magnetometer


(Compass)

Acceleration Rotation speed Direction of


along 3 axes around 3 axes magnetic north
𝑑2 𝑥 𝑑 2 𝑦 𝑑2 𝑧 𝑑𝜃𝑥 𝑑𝜃𝑦 𝑑𝜃𝑧
{ , , } { , , } {𝑚𝑥 , 𝑚𝑦 , 𝑚𝑧 }
𝑑𝑡 2 𝑑𝑡 2 𝑑𝑡 2 𝑑𝑡 𝑑𝑡 𝑑𝑡

Popular since they are inexpensive, small, and power efficient


Can be embedded inside any object to enable intelligence
Accelerometer
Basic model (1D)

𝐹𝑘
Accelerometer measures
𝑚

𝑚𝑎𝑎𝑐𝑐𝑙

𝐹𝑘 = 𝑚𝑔
𝐹𝑘
𝐴𝑚𝑒𝑎𝑠𝑢𝑟𝑒𝑑 = = 𝑔 Accelerometer output under
𝑚 rest is non-zero. It measures g
𝑚𝑎𝑎𝑐𝑐𝑙 = 𝐹𝑘 − 𝑚𝑔
𝐹𝑘 Accelerometer output under motion
𝐴𝑚𝑒𝑎𝑠𝑢𝑟𝑒𝑑 = = 𝑔 + 𝑎𝑎𝑐𝑐𝑙
𝑚

Accelerometers measure sum of acceleration due to motion and gravity

Smartphone accelerometers are tri-axial – can measure 3D acceleration


Accelerometer under free fall
Accelerometer measures ZERO in free fall

Zero
G = 9.8 m/s2
Measuring linear motion (1D)
𝐴𝑚𝑒𝑎𝑠𝑢𝑟𝑒𝑑 = 𝑔 + 𝑎𝑎𝑐𝑐𝑙

𝑎𝑎𝑐𝑐𝑙 = 𝐴𝑚𝑒𝑎𝑠 − 𝑔 Need to subtract gravity to obtain


acceleration due to motion
𝑑2𝑥
= Ameas − g
𝑑𝑡 2

𝑑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
𝑎𝑥

y 1D equation → 𝐴𝑚𝑒𝑎𝑠 = 𝑎𝑎𝑐𝑐𝑙 + 𝑔


𝑎𝑦

2D equations (y axis pointing upwards)


x 𝐴𝑥 = 𝑎 𝑥
𝜃 𝐴𝑦 = 𝑎𝑦 + 𝑔

g
Subtraction of gravity in 2D
1D equation → 𝐴𝑚𝑒𝑎𝑠 = 𝑎𝑎𝑐𝑐𝑙 + 𝑔

x 2D equations (y axis pointing upwards)


𝐴𝑥 = 𝑎 𝑥
𝜃 𝐴𝑦 = 𝑎𝑦 + 𝑔

2D equations (arbitrary rotation of phone)

𝐴𝑥 = 𝑎𝑥 + 𝑔𝑠𝑖𝑛𝜃
g 𝐴𝑦 = 𝑎𝑦 + 𝑔𝑐𝑜𝑠𝜃

We need to know the the orientation 𝜃 to subtract gravity

Inaccurate orientation will not eliminate gravity, resulting in errors (which accumulate over time)
An interesting idea
2D equations (arbitrary rotation of phone)

𝐴𝑥 = 𝑎𝑥 + 𝑔𝑠𝑖𝑛𝜃

𝐴𝑦 = 𝑎𝑦 + 𝑔𝑐𝑜𝑠𝜃

Suppose the phone is at rest, then 𝑎𝑥 = 0, 𝑎𝑦 = 0

𝐴𝑥 = 𝑔𝑠𝑖𝑛𝜃

𝑔
𝑠𝑖𝑛𝜃 =
𝐴𝑥

Accelerometer is an orientation sensor!!


Need the accelerometer to be at rest to estimate rotation
However accelerometer alone is not sufficient if we need 3D orientation, more later ..
Accelerometer to measure distance
𝑡 𝑡
• Double integration fails dramatically – 𝑥 = ඵ 𝐴 − 𝑔 𝑑𝑡 + ඵ 𝑛 𝑑𝑡
0 0
• However, accelerometer is good in tracking steps
Steps

Distance = step_count * step_size


Combining distance estimates with compass directions, we can dead reckon
Accelerometer
• Measures gravity + linear acceleration
• When static, gravity measurement can be used to sense orientation
• Double integrating accelerometer will accumulate error dramatically,
step counting is reasonable
Magnetometer
Measures magnetic north (2D example)
Magnetic north
y
Consider a 2D example

𝑀𝑦 = 𝑀
𝑀𝑥 = 0
x
Measures magnetic north (2D example)
Magnetic north
y Suppose, phone rotates in 2D by an angle

𝑀𝑦 = 𝑀𝑐𝑜𝑠𝜃
x 𝑀𝑥 = 𝑀 𝑠𝑖𝑛𝜃

The same concept generalizes to 3D,


3D magnetometer output {𝑀𝑥 , 𝑀𝑦 , 𝑀𝑧 } depends on phone orientation

Magnetometer can be used to sense the orientation


𝑀𝑥
𝑠𝑖𝑛𝜃 =
𝑀
However, in 3D magnetometer alone is insufficient to determine the orientation
3D orientation
Foundations of 3D Orientation

Up

East
Z
X

North

Global Frame Local Frame

18
Consider a phone in random orientation

Up

East
X Z

North

3D Orientation captures the misalignment between global and local frames

19
Rotation Matrix

𝑉
Up

East
In global frame
X Z
In local frame
Y

𝑥𝑙 ⋯ 𝑥𝑔
North Rotation
𝑦𝑙 = ⋮ ⋱ ⋮ 𝑦𝑔
𝑧𝑙 Matrix R 𝑧𝑔

R is the 3x3 Rotation Matrix


3x3 Rotation matrix captures the full 3D orientation
20
How can we estimate rotation matrix?

Key idea  use globally known reference vectors


which can also be measured in the local frame of reference
• Gravity
• Magnetic North
Gravity equation
Gravity globally known, measurable in local frame with accelerometer

𝑎𝑥 ⋯ 0 𝑚𝑥 ⋯ 0
Rotation
𝑎𝑦 = ⋮ ⋱ ⋮ Rotation
𝑚𝑦 = ⋮ ⋱ ⋮
0 𝑀
𝑎𝑧 Matrix R 𝑚𝑧 Matrix R
−𝑔 0

Magnetic north, globally known, measurable in local frame with magnetometer

6 equations and 9 unknowns (3x3 rotation matrix) can we solve ?

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

The above 6 equations are sufficient to solve the rotation matrix

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 cos(𝑦𝑎𝑤) −sin(𝑦𝑎𝑤) 0


3x3 Rotation 0 cos(𝑟𝑜𝑙𝑙) sin(𝑟𝑜𝑙𝑙) sin(𝑦𝑎𝑤) cos(𝑦𝑎𝑤) 0
= 0 1 0
Matrix R 0 0 1
sin(𝑝𝑖𝑡𝑐ℎ) 0 cos(𝑝𝑖𝑡𝑐ℎ) 0 −sin(𝑟𝑜𝑙𝑙) 𝑐𝑜𝑠(𝑟𝑜𝑙𝑙)

Orientation can be represented as 3D yaw, pitch, roll

Estimating yaw, pitch, roll will determine the orientation


Accelerometer equation
𝑎𝑥 ⋯ 0
Rotation
𝑎𝑦 = ⋮ ⋱ ⋮ 0
𝑎𝑧 Matrix R
𝑔

𝑎𝑥 cos(𝑝𝑖𝑡𝑐ℎ) 0 −sin(𝑝𝑖𝑡𝑐ℎ) 1 0 0 cos(𝑦𝑎𝑤) −sin(𝑦𝑎𝑤) 0 0


𝑎𝑦 = 0 1 0 0 cos(𝑟𝑜𝑙𝑙) sin(𝑟𝑜𝑙𝑙) sin(𝑦𝑎𝑤) cos(𝑦𝑎𝑤) 0 0
𝑎𝑧 sin(𝑝𝑖𝑡𝑐ℎ) 0 cos(𝑝𝑖𝑡𝑐ℎ) 0 −sin(𝑟𝑜𝑙𝑙) 𝑐𝑜𝑠(𝑟𝑜𝑙𝑙) 0 0 1 −𝑔
Accelerometer equation
𝑎𝑥 ⋯ 0
Rotation
𝑎𝑦 = ⋮ ⋱ ⋮ 0
𝑎𝑧 Matrix R
𝑔

𝑎𝑥 cos(𝑝𝑖𝑡𝑐ℎ) 0 −sin(𝑝𝑖𝑡𝑐ℎ) 1 0 0 0
𝑎𝑦 = 0 1 0 0 cos(𝑟𝑜𝑙𝑙) sin(𝑟𝑜𝑙𝑙) 0
𝑎𝑧 sin(𝑝𝑖𝑡𝑐ℎ) 0 cos(𝑝𝑖𝑡𝑐ℎ) 0 −sin(𝑟𝑜𝑙𝑙) 𝑐𝑜𝑠(𝑟𝑜𝑙𝑙) −𝑔

Accelerometer output does not depend on yaw!

Hence, yaw cannot be estimated using accelerometer


Accelerometer equation
𝑎𝑥 ⋯ 0
Rotation
𝑎𝑦 = ⋮ ⋱ ⋮ 0
𝑎𝑧 Matrix R
−𝑔

𝑎𝑥 −sin 𝑝𝑖𝑡𝑐ℎ . cos 𝑟𝑜𝑙𝑙 . 𝑔


𝑎𝑦 = − sin 𝑟𝑜𝑙𝑙 . 𝑔
𝑎𝑧 − cos 𝑝𝑖𝑡𝑐ℎ . cos 𝑟𝑜𝑙𝑙 . 𝑔

The above equations estimate pitch and roll


Magnetometer equation
𝑚𝑥 ⋯ 0
Rotation
𝑚𝑦 = ⋮ ⋱ ⋮ 𝑀
𝑚𝑧 Matrix R
0

𝑚𝑥 cos(𝑝𝑖𝑡𝑐ℎ) 0 −sin(𝑝𝑖𝑡𝑐ℎ) 1 0 0 cos(𝑦𝑎𝑤) −sin(𝑦𝑎𝑤) 0 0


𝑚𝑦 = 0 1 0 0 cos(𝑟𝑜𝑙𝑙) sin(𝑟𝑜𝑙𝑙) sin(𝑦𝑎𝑤) cos(𝑦𝑎𝑤) 0 𝑀
𝑚𝑧 sin(𝑝𝑖𝑡𝑐ℎ) 0 cos(𝑝𝑖𝑡𝑐ℎ) 0 −sin(𝑟𝑜𝑙𝑙) 𝑐𝑜𝑠(𝑟𝑜𝑙𝑙) 0 0 1 0
Magnetometer equation
𝑚𝑥 ⋯ 0
Rotation
𝑚𝑦 = ⋮ ⋱ ⋮ 𝑀
𝑚𝑧 Matrix R
0

𝑚𝑥 cos(𝑝𝑖𝑡𝑐ℎ) 0 −sin(𝑝𝑖𝑡𝑐ℎ) 1 0 0 cos(𝑦𝑎𝑤) −sin(𝑦𝑎𝑤) 0 0


𝑚𝑦 = 0 1 0 0 cos(𝑟𝑜𝑙𝑙) sin(𝑟𝑜𝑙𝑙) sin(𝑦𝑎𝑤) cos(𝑦𝑎𝑤) 0 𝑀
𝑚𝑧 sin(𝑝𝑖𝑡𝑐ℎ) 0 cos(𝑝𝑖𝑡𝑐ℎ) 0 −sin(𝑟𝑜𝑙𝑙) 𝑐𝑜𝑠(𝑟𝑜𝑙𝑙) 0 0 1 0

Pitch, roll known from accelerometer


Unknown yaw can be determined from above equations

yaw, pitch, roll together determine the rotation matrix (3D orientation) of a system
Gyroscope
1D example
• Measures angular velocity

𝑔𝑦𝑟𝑜 = 𝜔
𝑑𝜃
= 𝜔
𝑑𝑡
𝑑𝜃
= 𝜔 + 𝑛𝑜𝑖𝑠𝑒
𝑑𝑡
𝑡 𝑡 Error
𝜃 = න 𝜔 . 𝑑𝑡 + න 𝑛𝑜𝑖𝑠𝑒 . 𝑑𝑡
0 0

Time

Error accumulates over time


3D rotation estimation with gyroscope

𝜔𝑥
3D angular velocity 𝜔𝑦
𝜔𝑧

dR: 3x3 Matrix


Rotation Matrix R(t+1) = Rotation Matrix R(t)
(from Gyroscope)

Captures relative rotation between two times


3D rotation estimation with gyroscope

Gyroscope Measurements

Rotation Matrix dR(t+N-1) dR(t+1) dR(t) Rotation


= ……
R(t+N-1) 3x3 3x3 3x3 Matrix R(t)

Error accumulates with time with dRs have errors


gyroscope integration
Summary: two ways to measure orientation
• Using gyroscope
• Error accumulates
Error

Time

• Using accelerometer and compass


• Big advantage: No error accumulation ( since there is no integration involved)
• Accelerometer’s gravity measurement can be corrupted with linear motion
𝐴𝑚𝑒𝑎𝑠𝑢𝑟𝑒𝑑 = 𝑔𝑟𝑎𝑣𝑖𝑡𝑦 + 𝑎𝑚𝑜𝑡𝑖𝑜𝑛
• Accelerometer can measure orientation only when the phone is static
• Magnetometer is susceptible to electromagnetic interference
Recall UnLoc
Can we correct gyro drift using
accelerometer/magnetometer like UnLoc
High level idea to combine the two
• Use gyroscope to track orientation in general
• Errors will accumulate (drift)
Gyro
Gyro + Magn + Accl

Error

Time

• Reset errors with accelerometer/magnetometer (When the phone is


static and no magnetic interference)

You might also like