0
\$\begingroup\$

I have acceleration readings on 3 axes from an accelerometer, I'm trying to find a way to get the acceleration in the vertical direction independent of the current orientation of the sensor. I have been trying to google and search on forums but having a hard time finding a coherent answer. Thank you

\$\endgroup\$
0
\$\begingroup\$

To subtract the acceleration that counteracts gravity, you need to know your current orientation (i.e. you need a six axis accelerometer). Then the problem reduces to subtracting a vector of length \$9.81\frac{\textrm{m}}{\textrm{s}^2}\$ in the appropriate direction (and realistically, you also need to determine the gain and offset errors for each axis sensor, but a highpass filter will probably do for most applications).

Without knowing your orientation, no solution is possible, because the problem is under-defined.

\$\endgroup\$
  • \$\begingroup\$ Sorry I should have worded that differently, I do know my orientation (pitch, roll, yaw), I meant I would like to get the vertical acceleration regardless of how the sensor is oriented, so for example if it's at an angle how would I transform the readings to get the vertical acceleration. Thanks \$\endgroup\$ – user204581 Nov 16 '18 at 16:29
  • \$\begingroup\$ @czarsimon, apply a rotation matrix \$\endgroup\$ – Simon Richter Nov 16 '18 at 17:03
  • \$\begingroup\$ Could you provide an example in 3D? Thank you \$\endgroup\$ – user204581 Nov 16 '18 at 17:12
  • \$\begingroup\$ @czarsimon, the Wikipedia page has examples in 3D. \$\endgroup\$ – Simon Richter Nov 16 '18 at 18:54
0
\$\begingroup\$

You can solve by the theorem of pythagoras and by projection of vectors

a² + b² = c²

and

proj u  v = (< u.v >/< v.v >) * v

use 9.81 m / s² as the acceleration vector vector (if you are working with vector projection you can use vector projection - https://en.wikipedia.org/wiki/Vector_projection)

subtract the projection of the value of the angle, to the axis that you need

this way you can know in the three axes x, y and z the values for acceleration of gravity

\$\endgroup\$
  • \$\begingroup\$ Welcome to EE.SE, Mateus. Your answer seems accurate but loses some credibility due to missing capitalisation and punctuation. I encourage you to write properly as per How to write a good answer in the site help section. There's an edit link under your post. \$\endgroup\$ – Transistor Nov 16 '18 at 17:35
0
\$\begingroup\$

Knowing the attitude, you can make a vector sum. What you need is a 9DOF sensor (acc, gyro, mag) and a fusion algroithm - Sebastian Madgwick. His algorith will output quaternions of attitude. You will need to rotate the acceleration vector with attitude and then extract only the z-axis component.

\$\endgroup\$
0
\$\begingroup\$

I found a solution that worked, to calculate the vertical component of the acceleration in Earth frame given the orientation angles:

$$ \beta, \gamma = pitch, roll \\ z = -a_{x}sin(\beta) + a_{y}sin(\gamma)cos(\beta) + a_{z}cos(\gamma)cos(\beta) $$

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy