Reputation: 29
Im working on a Quadrotor project and i want to read data from my imu. i tried mpu6050 library but got just accelerometer and gyro data. i don't know how to access magnetometer data and use all these information to calculate pitch roll and yaw. the sensor Im using is GY9250. Im new in this field and i don't know mathematics. ill be glad if someone can help me. thank you... this is what i did:
accelgyro.getAcceleration(&ax, &ay, &az);
//Low Pass Filter
fXa = ax * alpha + (fXa * (1.0 - alpha));
fYa = ay * alpha + (fYa * (1.0 - alpha));
fZa = az * alpha + (fZa * (1.0 - alpha));
accelgyro.getRotation(&gx, &gy, &gz);
//pitch and roll
roll = (atan2(-fYa, fZa)*180.0)/M_PI;
pitch = (atan2(-fXa, fZa)*180.0)/M_PI;
Upvotes: 1
Views: 4421
Reputation: 384
If you look at the image below you can see that MPU has Digital Motion Processor.
The embedded Digital Motion Processor (DMP) is located within the MPU-60X0 and offloads computation of motion processing algorithms from the host processor.
The DMP acquires data from accelerometers, gyroscopes, and additional 3rd party sensors such as magnetometers, and processes the data. The resulting data can be read from the DMP’s registers, or can be buffered in a FIFO.
The DMP has access to one of the MPU’s external pins, which can be used for generating interrupts.
Then I would suggest you to read this article: http://playground.arduino.cc/Main/MPU-6050
And of course read this one too: http://www.varesano.net/projects/hardware/FreeIMU
Upvotes: 2