Jump to content
I2Cdevlib Forums

ekchess

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by ekchess

  1. I had the same question and solved the problem for my application, although I have not tested others. I wanted to access the ypr functions from the DMP, but wanted to orient the breakout board so the Y-axis was vertical. I only cared about pitch and roll in this new configuration. When you reorient the board, the Y-axis becomes the vertical, and the Z-axis becomes equitorial, in effect swapping roles. The X-axis stays in the same plane (albeit 90 degrees out of the old position). By looking at MPU6050_6Axis_MotionApps20.h file from Jeff Rowland, I found where the GetYawPitchRoll function was defined. I simply swapped all instances of y and z in these three definitions and it worked well for pitch and roll. I saw some discontinuity in the yaw motion, but since I was not interested in it, I did not investigate further. Sample code is below. Old version: uint8_t MPU6050::dmpGetYawPitchRoll(float *data, Quaternion *q, VectorFloat *gravity) { // yaw: (about Z axis) data[0] = atan2(2*q -> x*q -> y - 2*q -> w*q -> z, 2*q -> w*q -> w + 2*q -> x*q -> x - 1); // pitch: (nose up/down, about Y axis) data[1] = atan(gravity -> x / sqrt(gravity -> y*gravity -> y + gravity -> z*gravity -> z)); // roll: (tilt left/right, about X axis) data[2] = atan(gravity -> y / sqrt(gravity -> x*gravity -> x + gravity -> z*gravity -> z)); return 0; } New version: uint8_t MPU6050::dmpGetYawPitchRollOnEnd(float *data, Quaternion *q, VectorFloat *gravity) { // yaw: (about Y axis) data[0] = atan2(2*q -> x*q -> z - 2*q -> w*q -> y, 2*q -> w*q -> w + 2*q -> x*q -> x - 1); // pitch: (nose up/down, about Z axis) data[1] = atan(gravity -> x / sqrt(gravity -> z*gravity -> z + gravity -> y*gravity -> y)); // roll: (tilt left/right, about X axis) data[2] = atan(gravity -> z / sqrt(gravity -> x*gravity -> x + gravity -> y*gravity -> y)); return 0; } I hope this helps in part with your problems. The sensor board calibration was done in the usual fashion before swapping the axes in code, but the calibrations held up well.
  2. I downloaded the calibration sketch today, 5-Mar-2016, v1.1, and used it to calibrate a new MPU6050 breakout board using an Arduino Uno. The sketch worked perfectly. Thank you, luisrodenas, for the development and updates.
×
×
  • Create New...