0

I have MPU6050 accelerometer and gyroscope MEMS sensor for calculate roll and pitch. Bu this calculation now enough my project.

In my project, sensor is on the top of the box. My idea is to calculate the tipping state of the box with a single angle. Box as below:

box and sensor representation

The green vector will always be perpendicular to earth vector. The blue vector is always perpendicular to the sensor. If I have a vector perpendicular to the sensor and a vector perpendicular to the earth, I can calculate the tipping condition with a single data by calculating the angle between these two vectors.

So my question is how can i get these two vectors from roll and pitch?

  • Do you mean the green vector points to the center of the earth, and you want to determine the angle between that vector and a fixed (relative to the box) vector? – Ian Abbott Sep 30 '21 at 15:48
  • Angle between vectors `a` and `b` in radians should be something like `acos((a.x * b.x + a.y * b.y + a.z * b.z) / sqrt((a.x * a.x + a.y * a.y + a.z * a.z) * (b.x * b.x + b.y * b.y + b.z * b.z)))`. (`a.x * b.x + a.y * b.y + a.z * b.z` is the dot product of `a` and `b`, `a.x * a.x + a.y * a.y + a.z * a.z` is the squared magnitude of `a`, `b.x * b.x + b.y * b.y + b.z * b.z` is the squared magnitude of `b`.) – Ian Abbott Sep 30 '21 at 16:07
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 08 '21 at 00:25

0 Answers0