简体   繁体   中英

How to get gravity values from real acceleration date using MPU 9150 sensor

Please kindly help me to learn

I can get acceleration values using below code

    #ifdef OUTPUT_READABLE_REALACCEL
    //display real acceleration, adjusted to remove gravity
    mpu.dmpGetQuaternion(&q, fifoBuffer);
    mpu.dmpGetAccel(&aa, fifoBuffer);
    mpu.dmpGetGravity(&gravity, &q);
    mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
    Serial.print("areal\t");
    Serial.print(aaReal.x);
    Serial.print("\t");
    Serial.print(aaReal.y);
    Serial.print("\t");
    Serial.println(aaReal.z);
    #endif

How to get gravity values from real acceleration date using MPU 9150 sensor.

Thanks in advance.

If you could tell what MPU libraries are you using that would be great, but I am assuming you are using Jeff Rowberg's ones with helper_3dmath.

From code you have attached you can notice dmpGetGravity method that populates your VectorFloat. This data class contains x, y, z parameters that corresponds to the gravity that is applied on the given axis (for example sensor facing towards sky with no movement in fixed position, should show 16384.0f for z parameter and assumable 0 for the rest). You can also retrieve normalized data which is basically every parameter divided by the magnitude calculated by the class itself, based on the data.

Results does not have to be accurate depending on how your sensor is calibrated and how close offsets you set.

I am not sure if it is what you are looking for, but hope it is. I did not test it though, but I have some experience with these libraries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM