# roll, pitch - Brian Lavery

```“Degrees of Freedom”
An often abused term !
3 DoF: Linear along X or Y o Z
3 Dof: Rotate around X or Y or Z
Total 6 DoF !
AXIS CONVENTION:
Thumb, finger 1, finger2
are X Y Z
Linear Movement in 3
axes:
Imagine a plane accelerating for takeoff:
Forward movement. (Say Y)
Then lifts off & starts climbing:
Add an upward movement. (Say Z)
Then a side gust starts pushing it to the right a little:
Add a sideways movement. (Say X)
So which direction is it then travelling?
http://www.city-gallery.com/knoblock/projects/flightgear/Docs/coords.html
ROTATING
http://toronto-soaring.ca/wordpress/?page_id=30
https://howthingsfly.si.edu/flight-dynamics/roll-pitch-and-yaw

We will use this orientation:
X=to our right side
Z=Up
ROTATION CONVENTION:
Look forward along each axis.
Rotation clockwise is called POSITIVE.
Practice: Point thumb, forefinger &
middle finger to X Y and Z
Same axes on phone
Recall:
ROTATION CONVENTION:
Look forward along each axis.
Rotation clockwise is called
POSITIVE.
So, this diagram (from the web)
has ROLL and YAW wrong! Not
everyone is careful !
(Again, practice thumb, forefinger, middle finger)
Experiment with PiGyro and your
phone


Experiment in PiGyro with roll and pitch. Watch the
changeovers from 0 degrees, 90 degrees, 180 degrees,
and positive and negative.
For “yaw” we will use simply compass bearing, which is
easy to understand. 0 – 359 degrees.
Roll, pitch and yaw have some different conventions!
(to 90, to 180, to 360, wraparound, or jumping to negative)
We also need to
decide an “axis
convention” for
our IMU board/
The “Brian” convention:
For our board as shown above,
Y (forward) = upwards on picture
X (sideways) to right
Z (up) out above the board towards
you
We hope the several chips on our
module have X Y Z agreeing with
the “Brian Convention” for our
agreed axes.
They don't !
Check Chip Specs …
LSM303D
Accelerometer X Y X
Magnetometer X Y Z
L3GD20
Gyro (rotational velocity) X Y Z
Things we “really” measure
These are the four sensors (in 3 chips) on the IMU:
1.Acceleration / force in directions x y z
2.(Earth's) magnetism in x y z
3.Air pressure
4.Angular velocity in x y z (the “gyro”)
A total of 10 raw numbers (values)
The maths / physics:






Velocity (speed) is how fast location is changing
metres / second
Acceleration is how fast speed is changing
(metres / second ) / second
Gravity is same as acceleration (to a physicist)
metres / second / second
Acceleration is directly proportional to force
force = mass x acceleration
Angular velocity is how fast we are rotating
degrees / second
Air pressure falls as we rise upwards
Frames of Reference.
A manoeuvering fighter jet pilot might want to know
everything relative to his own aircraft X Y Z. “Is that the
ground out my left window?” (in my minus X direction)
An observer on ground might want to see that aircraft
relative to a flat earth X Y Z. “That jet has 90 degree roll
to left.”
Einstein (et al) insist each frame of reference is fully valid.
PyGyro
From its own “raw”
of reference,
The phone is showing us
three “derived” results,
that are more related to a
human interpretation on
our flat earth surface.
How does it know what's “horizontal”,
to compute roll & pitch?
Gravity = acceleration.
There is one massive “acceleration” constantly there in
the readings pointing to earth's centre.
1. Extremely handy. We can now compute “horizontal”.
2. Extremely awkward. Other smaller “accelerations”
from real motion get dwarfed by the gravity value.
Useful things we can derive from the
raw values
1.Orientation relative to flat ground
(roll, pitch) *
We measure against earth's gravity
2.Bearing on compass *
(yaw)
We measure against earth's magnetic lines
3.Height above sea level
4.Angular x y z velocities
(on their own, probably not much use to us?)
5.Short term “bumps” (short acceleration forces) *
* Things you can see on PyGyro demo
Seeing some real motion on PiGyro
This is a bit rough.
Hold phone as horizontal as you can.
Walk quite quickly about 6 feet to left then right.
(OR slide it on a benchtop, to keep it horizontal.)
speed up & stop & then return.
Similarly “Pitch” might register a fluctuation if you walk quickly a
few feet forward and back.
It's not really roll or pitch, you've confused the simple program. It's
acceleration of you moving.
Why can't we have EVERYTHING ?




Velocity/speed in 3D
(ie how fast, & which direction are we going)
Current position in 3D
(up/down, left/right, forward/back)
Speed of rotation & what direction
(are we tumbling)
Current “orientation”
(roll/pitch/yaw)


If we kept a running total on every moment of
acceleration, couldn't we track current velocity?
If we then kept a running total on every moment
of velocity, couldn't we track current position?
A seat of a taking-off aircraft pushes us in the back. If we
used a force-gauge and a stopwatch and clever fast
calculator, could we (windows pulled down, can't see out)
work out just when we cross the runway's end, and our
groundspeed then?
In a month ...
Connecting our new “IMU” to Raspberry Pi and getting
some “raw” values from it.
Then, in a following class,
Getting good useful information from that raw data.
How far can we “push” this tiny gadget?
Some fun experiments and snazzy live graphic plots.
```