Description Usage Arguments Details Value Author(s) References See Also Examples
calculate pitch angle using measurements from a three-axis accelerometer and roll angle.
1 |
x |
a numeric vector of x-axis values. |
y |
a numeric vector of y-axis values. |
z |
a numeric vector of z-axis values. |
roll |
numeric vector of roll angles. (-π ≤ |
pitch2()
will return a pitch angle (in radians) representing the posterior-anterior axis position of the animal. This angle is the difference between the posterior-anterior axis (vector) of the animal and the horizon. This angle is calculated assuming the NED (north, east, down) frame of reference. Typically, this is measured with an accelerometer and is scaled from -1 to +1. Using the NED frame of reference means that when the accelerometer is measuring 1g, this is equal to -9.8 m/s^2. Also, if the axis is aligned with the earth gravity vector (i.e. down, towards the center of the earth), it should have a value of +1. Pitch angle is calculated by
pitch = atan(-x/(y*sin(roll)+(z*cos(roll))) )
A positive pitch value indicates that the nose of the animal (x-axis) is pitched upward (toward the sky). Conversely, a negative pitch angle indicates that the animal is pitched downward. (Note: axis values must be converted to NED frame of reference prior to using this function)
an object of pitch values (in radians) from -π/2 ≤ pitch
≤ π/2
Ed Farrell <edward.farrell27@gmail.com>
Ozyagcilar, T. (2012), Implementing a tilt-compensated eCompass using accelerometer and magnetometer sensors. Freescale semiconductor, AN 4248, Rev. 3.
Smith, K. J. (1998), Essentials of Trigonometry. Pacific Grove, CA: Brooks/Cole.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Import the yaw, pitch and roll simulated calibration dataset. For
## an explanation of the data use help(yprsim).
data(yprsim)
## Accelerometer axes
ax <- yprsim$ax
ay <- yprsim$ay
az <- yprsim$az
## Calculate roll
theta <- roll(ay, az)
## Calculate pitch (the nose/x-axis is rotated downward through 2 full rotations)
phi <- pitch2(ax, ay, az, theta)
## Plot
plot(phi*(180/pi),type='l',lty=1,lwd=2,xlab="time (s)",ylab="pitch (degrees)",
main="Pitch2 Calculation (2 pitch rotations)")
abline(v=c(126,252),lty=3,lwd=2)
legend(-10,70,legend=c("Pitch","Change in \n Rotation"),
col=c("black","black"),lty=c(1,3),bty="n")
text(50,-70,"Yaw");text(175,-70,"Pitch");text(320,-70,"Roll")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.