Replies: 5 comments
-
Pitch and roll should already be absolute, since orientation is computed according to gravity. Yaw is the only one that can drift without an absolute magnetic heading reference. Do you have the IMU chip itself mounted on a PCB such that it's flat/level relative to the ground? Or is it at 90 degrees in any direction? |
Beta Was this translation helpful? Give feedback.
-
Well I have the MPU6050 module placed on a breadboard alongside the Pro Mini 3.3V board, but whenever I power the setup it will take it's initial position as reference, something I don't want. I have a model glider for which PITCH axis will be used only at the launch for a few seconds and then the YAW axis will be used to guide the glider to a specific direction, set by a potentiometer, I don't need the true azimuth, just a reference. Only for the PTCH axis I want absolute readings relative to earth, because on the field I can't position the glider perfectly level when powering on. I will post a link to a video to see what's happening. Thank you! |
Beta Was this translation helpful? Give feedback.
-
How can I read the absolute orientation regarding earth? |
Beta Was this translation helpful? Give feedback.
-
Please help me... :( |
Beta Was this translation helpful? Give feedback.
-
It looks like what you're trying to do isn't possible based on the order you are executing each step. When you power on the IMU and take it out of sleep mode, the raw accel/gyro axes start gathering data, but that's just linear acceleration (movement + gravity) and rotational velocity--not orientation. Then, when you load the DMP binary code, it uses the orientation at that moment (as far as I know) as the "zero/flat/level" reference orientation. As a result, the yaw/pitch/roll values are based on that initial orientation. You then appear to flip the IMU exactly 90 degrees, which is actually the worst thing you can do if you're using Euler angles (Y/P/R), because you immediately enter a situation where gimbal lock is an issue. Not only does this mean your axes are (apparently) 90 degrees off from what you want, but you'll also start seeing wildly fluctuating values for certain types of rotation, because of what happens when you represent orientation as 3 angle values: The DMP in the IMU internally computes orientation data as quaternions, which provide a 4-dimensional space to work with. Quaternions don't suffer from gimbal lock, which makes them much better--mathematically speaking--than Euler representation. But it looks like your main problem is that you actually want the reference orientation to be 90 degrees different. There are two ways to accomplish this.
Option 1 is the easiest if you have the physical ability to do so, since it means your code can stay the same. Option 2 is the most flexible, but requires some arcane math that (not awful if you can find code for it, though it might impact the performance of a very low-powered MCU). Basically, for Option 2 you have to choose your own "zero" orientation value, then multiply all incoming quaternions by the inverse of the zero reference quaternion. The yaw/pitch/roll values will be zero when the IMU is oriented as it was when you set the zero point. One risk here is that if you use a live orientation value as your zero point when the IMU is not perfectly flat/level, you might (or will, probably) end up with an offset to your pitch and roll values--in other words, pitch=0 & roll=0 won't actually be where gravity is straight down. If you know you're going to rotate the IMU physically 90 degrees relative to where you loaded the DMP, you can apply a precalculated 90-degree single-axis rotation quaternion around instead of using a live reference value: https://stackoverflow.com/questions/4436764/rotating-a-quaternion-on-1-axis/4436915#4436915 There might be a way to configure this reorientation to occur inside the IMU/DMP, but I'm not sure. Some IMUs support this, but I've been out of the InvenSense/TDK part and development world for a decade, so I'm not sure what made it into the MPU6050 libraries before they stopped updating them. |
Beta Was this translation helpful? Give feedback.
-
Hi! I used the MPU6050_DMP6 code and it's working very well, but I have a problem, I seem to be reading relative orientation, I'm more interested in PITCH to be absolute and YAW to be relative. How can I do that? Thank you in advance!
Beta Was this translation helpful? Give feedback.
All reactions