简体   繁体   中英

Getting calclated values from mpu 9150

for a school project we got a mpu 9150 (Gyro/Accelerometer/Magnetometer(?)) and we want to get Roll/Pitch/Yaw/Heading for it.

I used a code that was as an example in the libary, but it gives us only the raw datas in that format: ax/ay/az/gx/gy/gz/mx/my/mz. Thats not what we want.

I managed to get roll and pitch so far with the following snippet:

roll = atan2(ay, az)+PI;
pitch = atan2(-ax, az)+PI;

// Convert everything from radians to degrees:
pitch *= 180.0 / PI;
roll  *= 180.0 / PI;

And i read that i have to use the magnetometer to get the yaw, but i have no idea what formular i need for it.

In the example code there is also this snippet inside, maybe thats all i need to use or anyone knows other functions/methods i could use?

// read raw accel/gyro measurements from device
accelgyro.getMotion9(&ax, &ay, &az, &gx, &gy, &gz, &mx, &my, &mz);

// these methods (and a few others) are also available
//accelgyro.getAcceleration(&ax, &ay, &az);
//accelgyro.getRotation(&gx, &gy, &gz);

I working with the I2Cdev and MPU6050 libaries

Another question would be, what kind of things can i get from the sensor else? Is it possible to get the height or difference in height of it?

Thanks for help.

Raw values of your mpu are mostly very inexact, drifting away, ... not really usable. The MPU6050 libary is very useful to get useful values. To get your yaw/roll/pitch you could use the MPU6050 Libary like the example described in this example sketch . Just add

#define OUTPUT_READABLE_YAWPITCHROLL

on top this code an run it (with the right baudrate).

With your sensor it´s also possible to get the actual temperature.

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