Help! MPU6050 to read from 0 - 360 degrees

i know this is an old thread but i don't see a definitive answer to the question. did anyone work out yet how to get angles on 0-360? (or +/- 180)

i'm seeing the same problem as everyone else, when i pitch or roll past vertical the numbers start to decrease so, for example, there is no way to tell between as 45 degree and 135 degree pitch or roll (don't care about yaw)

thanks

UPDATE, i found this and it kinda works except when roll gets close to + or - 90, pitch goes crazy
https://forum.arduino.cc/index.php?topic=331084.msg2287736#msg2287736

UPDATE2
after a lot of testing i think Ps991 code for Roll is perfect. i've tested it at pitch angles 0, +/-45, +/-80, etc and looks good
as you get closer to a pitch of +/- 90, roll angle is kind meaningless anyhow

i think the pitch angle calculation in the original dmpGetYawPitchRoll if better, it doesn't go crazy with >90degree roll angles, however it does have the original problem that once you go past vertical in starts to go down again. in my app that's not a problem, but if it is a problem for you, look at the gravity values to detect when it flips past 90

I've started to play with this Chip, I've got it all working and displaying the data on an 20x4 LCD and the calibration part is working as it should. So I decided to replace the LCD for and .91" Oled but I cant get it to display anything on there

This is the code

#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
#include "Wire.h"
#include <Arduino.h>
#include <U8g2lib.h>
MPU6050 mpu;
U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);   // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED
// End of constructor list
#define DEBUG
#ifdef DEBUG
//#define DPRINT(args...)  Serial.print(args)             //OR use the following syntax:
#define DPRINTSTIMER(t)    for (static unsigned long SpamTimer; (unsigned long)(millis() - SpamTimer) >= (t); SpamTimer = millis())
#define  DPRINTSFN(StrSize,Name,...) {char S[StrSize];Serial.print("\t");Serial.print(Name);Serial.print(" "); Serial.print(dtostrf((float)__VA_ARGS__ ,S));}//StringSize,Name,Variable,Spaces,Percision
#define DPRINTLN(...)      Serial.println(__VA_ARGS__)
#else
#define DPRINTSTIMER(t)    if(false)
#define DPRINTSFN(...)     //blank line
#define DPRINTLN(...)      //blank line
#endif



#define LED_PIN 13 // 

// supply your own gyro offsets here, scaled for min sensitivity use MPU6050_calibration.ino
// -4232  -706  1729  173 -94 37
//                       XA      YA      ZA      XG      YG      ZG
int MPUOffsets[6] = {  -4232,  -706,   1729,    173,    -94,     37};


// ================================================================
// ===                      i2c SETUP Items                     ===
// ================================================================
void i2cSetup() {
  // join I2C bus (I2Cdev library doesn't do this automatically)
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
  Wire.begin();
  TWBR = 24; // 400kHz I2C clock (200kHz if CPU is 8MHz)
#elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
  Fastwire::setup(400, true);
#endif
}

// ================================================================
// ===               INTERRUPT DETECTION ROUTINE                ===
// ================================================================
volatile bool mpuInterrupt = false;     // indicates whether MPU interrupt pin has gone high
void dmpDataReady() {
  mpuInterrupt = true;
}

// ================================================================
// ===                      MPU DMP SETUP                       ===
// ================================================================
int FifoAlive = 0; // tests if the interrupt is triggering
int IsAlive = -20;     // counts interrupt start at -20 to get 20+ good values before assuming connected
// MPU control/status vars
uint8_t mpuIntStatus;   // holds actual interrupt status byte from MPU
uint8_t devStatus;      // return status after each device operation (0 = success, !0 = error)
uint16_t packetSize;    // expected DMP packet size (default is 42 bytes)
uint16_t fifoCount;     // count of all bytes currently in FIFO
uint8_t fifoBuffer[64]; // FIFO storage buffer

// orientation/motion vars
Quaternion q;           // [w, x, y, z]         quaternion container
VectorInt16 aa;         // [x, y, z]            accel sensor measurements
VectorInt16 aaReal;     // [x, y, z]            gravity-free accel sensor measurements
VectorInt16 aaWorld;    // [x, y, z]            world-frame accel sensor measurements
VectorFloat gravity;    // [x, y, z]            gravity vector
float euler[3];         // [psi, theta, phi]    Euler angle container
float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector
byte StartUP = 100; // lets get 100 readings from the MPU before we start trusting them (Bot is not trying to balance at this point it is just starting up.)

void MPU6050Connect() {
  static int MPUInitCntr = 0;
  // initialize device
  mpu.initialize(); // same
  // load and configure the DMP
  devStatus = mpu.dmpInitialize();// same

  if (devStatus != 0) {
    // ERROR!
    // 1 = initial memory load failed
    // 2 = DMP configuration updates failed
    // (if it's going to break, usually the code will be 1)

    char * StatStr[5] { "No Error", "initial memory load failed", "DMP configuration updates failed", "3", "4"};

    MPUInitCntr++;

    Serial.print(F("MPU connection Try #"));
    Serial.println(MPUInitCntr);
    Serial.print(F("DMP Initialization failed (code "));
    Serial.print(StatStr[devStatus]);
    Serial.println(F(")"));

    if (MPUInitCntr >= 10) return; //only try 10 times
    delay(1000);
    MPU6050Connect(); // Lets try again
    return;
  }
  mpu.setXAccelOffset(MPUOffsets[0]);
  mpu.setYAccelOffset(MPUOffsets[1]);
  mpu.setZAccelOffset(MPUOffsets[2]);
  mpu.setXGyroOffset(MPUOffsets[3]);
  mpu.setYGyroOffset(MPUOffsets[4]);
  mpu.setZGyroOffset(MPUOffsets[5]);

  Serial.println(F("Enabling DMP..."));
  mpu.setDMPEnabled(true);
  // enable Arduino interrupt detection
  Serial.println(F("Enabling interrupt detection (Arduino external interrupt pin 2 on the Uno)..."));
  Serial.print("mpu.getInterruptDrive=  "); Serial.println(mpu.getInterruptDrive());
  attachInterrupt(0, dmpDataReady, RISING); //pin 2 on the Uno
  mpuIntStatus = mpu.getIntStatus(); // Same
  // get expected DMP packet size for later comparison
  packetSize = mpu.dmpGetFIFOPacketSize();
  delay(1000); // Let it Stabalize
  mpu.resetFIFO(); // Clear fifo buffer
  mpu.getIntStatus();
  mpuInterrupt = false; // wait for next interrupt
}

// ================================================================
// ===                    MPU DMP Get Data                      ===
// ================================================================
void GetDMP() { // Best version I have made so far
  // Serial.println(F("FIFO interrupt at:"));
  // Serial.println(micros());
  static unsigned long LastGoodPacketTime;
  mpuInterrupt = false;
  FifoAlive = 1;
  fifoCount = mpu.getFIFOCount();
  if ((!fifoCount) || (fifoCount % packetSize)) { // we have failed Reset and wait till next time!
    digitalWrite(LED_PIN, LOW); // lets turn off the blinking light so we can see we are failing.
    mpu.resetFIFO();// clear the buffer and start over
  } else {
    while (fifoCount  >= packetSize) { // Get the packets until we have the latest!
      mpu.getFIFOBytes(fifoBuffer, packetSize); // lets do the magic and get the data
      fifoCount -= packetSize;
    }
    LastGoodPacketTime = millis();
    MPUMath(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<< On success MPUMath() <<<<<<<<<<<<<<<<<<<
    digitalWrite(LED_PIN, !digitalRead(LED_PIN)); // Blink the Light
  }
}


// ================================================================
// ===                        MPU Math                          ===
// ================================================================
float Yaw, Pitch, Roll;
void MPUMath() {
  mpu.dmpGetQuaternion(&q, fifoBuffer);
  mpu.dmpGetGravity(&gravity, &q);
  mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
  Yaw = (ypr[0] * 180.0 / M_PI);
  Pitch = (ypr[1] *  180.0 / M_PI);
  Roll = (ypr[2] *  180.0 / M_PI);
  DPRINTSTIMER(100) {
    DPRINTSFN(15, "\tYaw:", Yaw, 6, 1);
    DPRINTSFN(15, "\tPitch:", Pitch, 6, 1);
    DPRINTSFN(15, "\tRoll:", Roll, 6, 1);
    DPRINTLN();
      u8g2.clearBuffer();          // clear the internal memory
  u8g2.setFont(u8g2_font_osb29_tn); // choose a suitable font
  u8g2.setCursor(5,32);
  u8g2.print(Roll,2); // write something to the internal memory
  //u8g2.setFont(u8g2_font_fub30_tf);
  //u8g2.drawUTF8(115, 30, DEGREE_SYMBOL);
  u8g2.sendBuffer();          // transfer internal memory to the display
  }
}
// ================================================================
// ===                         Setup                            ===
// ================================================================
void setup() {
  u8g2.begin();
  Serial.begin(115200); //115200
  while (!Serial);
  Serial.println("i2cSetup");
  i2cSetup();
  Serial.println("MPU6050Connect");
  MPU6050Connect();
  Serial.println("Setup complete");
  pinMode(LED_PIN, OUTPUT);
}
// ================================================================
// ===                          Loop                            ===
// ================================================================
void loop() {
  if (mpuInterrupt ) { // wait for MPU interrupt or extra packet(s) available
    GetDMP();
  }
}

Sorry I was over the text limit and did not want to add it has a download so people could read it rather than download it.

But this the test code that works onmy OLED display , So I know the display is wired and working correctly but above code does not, I've checked all my setting and compered the stuff that should print

#include <Wire.h>
#include <Arduino.h>
#include <U8g2lib.h>
float Roll = 12.34;
U8G2_SSD1306_128X32_UNIVISION_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);   // Adafruit Feather ESP8266/32u4 Boards + FeatherWing OLED
// End of constructor list

const char DEGREE_SYMBOL[] = { 0xB0, '\0' };
void setup(void) {
  u8g2.begin();
}

void loop(void) {
   u8g2.clearBuffer();          // clear the internal memory
  u8g2.setFont(u8g2_font_osb29_tn); // choose a suitable font
  u8g2.setCursor(5,32);
  u8g2.print(Roll,2); // write something to the internal memory
  u8g2.setFont(u8g2_font_fub30_tf);
  u8g2.drawUTF8(115, 30, DEGREE_SYMBOL);
  u8g2.sendBuffer();          // transfer internal memory to the display
 
  u8g2.sendBuffer(); // transfer internal memory to the display
  delay(1000);  
}

zhomeslice:
To answer your original question Have you tried all the angle calculation functions your library provides? I know the dmpGetYawPitchRoll() uses gravity to measure pitch and roll so you are seeing angle to gravity (which works great for balancing bots). The dmpGetEuler() is closer to your request it is calculated relative to the object rather than the world. the dmpGetEuler returns radians so you still need to convert them to degrees.

Degrees = (radians * 180.0 / M_PI);
uint8_t MPU6050::dmpGetanAccel(int32_t *data, const uint8_t* packet) {

// TODO: accommodate different arrangements of sent data (ONLY default supported now)
   if (packet == 0) packet = dmpPacketBuffer;
   data[0] = (((uint32_t)packet[28] << 24) | ((uint32_t)packet[29] << 16) | ((uint32_t)packet[30] << 8) | packet[31]);
   data[1] = (((uint32_t)packet[32] << 24) | ((uint32_t)packet[33] << 16) | ((uint32_t)packet[34] << 8) | packet[35]);
   data[2] = (((uint32_t)packet[36] << 24) | ((uint32_t)packet[37] << 16) | ((uint32_t)packet[38] << 8) | packet[39]);
   return 0;
}
uint8_t MPU6050::dmpGetAccel(int16_t data, const uint8_t packet) {
   // TODO: accommodate different arrangements of sent data (ONLY default supported now)
   if (packet == 0) packet = dmpPacketBuffer;
   data[0] = (packet[28] << 8) | packet[29];
   data[1] = (packet[32] << 8) | packet[33];
   data[2] = (packet[36] << 8) | packet[37];
   return 0;
}
uint8_t MPU6050::dmpGetAccel(VectorInt16 v, const uint8_t packet) {
   // TODO: accommodate different arrangements of sent data (ONLY default supported now)
   if (packet == 0) packet = dmpPacketBuffer;
   v -> x = (packet[28] << 8) | packet[29];
   v -> y = (packet[32] << 8) | packet[33];
   v -> z = (packet[36] << 8) | packet[37];
   return 0;
}
uint8_t MPU6050::dmpGetQuaternion(int32_t data, const uint8_t packet) {
   // TODO: accommodate different arrangements of sent data (ONLY default supported now)
   if (packet == 0) packet = dmpPacketBuffer;
   data[0] = (((uint32_t)packet[0] << 24) | ((uint32_t)packet[1] << 16) | ((uint32_t)packet[2] << 8) | packet[3]);
   data[1] = (((uint32_t)packet[4] << 24) | ((uint32_t)packet[5] << 16) | ((uint32_t)packet[6] << 8) | packet[7]);
   data[2] = (((uint32_t)packet[8] << 24) | ((uint32_t)packet[9] << 16) | ((uint32_t)packet[10] << 8) | packet[11]);
   data[3] = (((uint32_t)packet[12] << 24) | ((uint32_t)packet[13] << 16) | ((uint32_t)packet[14] << 8) | packet[15]);
   return 0;
}
uint8_t MPU6050::dmpGetQuaternion(int16_t data, const uint8_t packet) {
   // TODO: accommodate different arrangements of sent data (ONLY default supported now)
   if (packet == 0) packet = dmpPacketBuffer;
   data[0] = ((packet[0] << 8) | packet[1]);
   data[1] = ((packet[4] << 8) | packet[5]);
   data[2] = ((packet[8] << 8) | packet[9]);
   data[3] = ((packet[12] << 8) | packet[13]);
   return 0;
}
uint8_t MPU6050::dmpGetQuaternion(Quaternion q, const uint8_t packet) {
   // TODO: accommodate different arrangements of sent data (ONLY default supported now)
   int16_t qI[4];
   uint8_t status = dmpGetQuaternion(qI, packet);
   if (status == 0) {
       q -> w = (float)qI[0] / 16384.0f;
       q -> x = (float)qI[1] / 16384.0f;
       q -> y = (float)qI[2] / 16384.0f;
       q -> z = (float)qI[3] / 16384.0f;
       return 0;
   }
   return status; // int16 return value, indicates error if this line is reached
}
// uint8_t MPU6050::dmpGet6AxisQuaternion(long data, const uint8_t packet);
// uint8_t MPU6050::dmpGetRelativeQuaternion(long data, const uint8_t packet);
uint8_t MPU6050::dmpGetGyro(int32_t data, const uint8_t packet) {
   // TODO: accommodate different arrangements of sent data (ONLY default supported now)
   if (packet == 0) packet = dmpPacketBuffer;
   data[0] = (((uint32_t)packet[16] << 24) | ((uint32_t)packet[17] << 16) | ((uint32_t)packet[18] << 8) | packet[19]);
   data[1] = (((uint32_t)packet[20] << 24) | ((uint32_t)packet[21] << 16) | ((uint32_t)packet[22] << 8) | packet[23]);
   data[2] = (((uint32_t)packet[24] << 24) | ((uint32_t)packet[25] << 16) | ((uint32_t)packet[26] << 8) | packet[27]);
   return 0;
}
uint8_t MPU6050::dmpGetGyro(int16_t data, const uint8_t packet) {
   // TODO: accommodate different arrangements of sent data (ONLY default supported now)
   if (packet == 0) packet = dmpPacketBuffer;
   data[0] = (packet[16] << 8) | packet[17];
   data[1] = (packet[20] << 8) | packet[21];
   data[2] = (packet[24] << 8) | packet[25];
   return 0;
}
uint8_t MPU6050::dmpGetGyro(VectorInt16 v, const uint8_t packet) {
   // TODO: accommodate different arrangements of sent data (ONLY default supported now)
   if (packet == 0) packet = dmpPacketBuffer;
   v -> x = (packet[16] << 8) | packet[17];
   v -> y = (packet[20] << 8) | packet[21];
   v -> z = (packet[24] << 8) | packet[25];
   return 0;
}
// uint8_t MPU6050::dmpSetLinearAccelFilterCoefficient(float coef);
// uint8_t MPU6050::dmpGetLinearAccel(long data, const uint8_t packet);
uint8_t MPU6050::dmpGetLinearAccel(VectorInt16 v, VectorInt16 vRaw, VectorFloat gravity) {
   // get rid of the gravity component (+1g = +8192 in standard DMP FIFO packet, sensitivity is 2g)
   v -> x = vRaw -> x - gravity -> x
8192;
   v -> y = vRaw -> y - gravity -> y
8192;
   v -> z = vRaw -> z - gravity -> z
8192;
   return 0;
}
// uint8_t MPU6050::dmpGetLinearAccelInWorld(long data, const uint8_t packet);
uint8_t MPU6050::dmpGetLinearAccelInWorld(VectorInt16 v, VectorInt16 vReal, Quaternion q) {
   // rotate measured 3D acceleration vector into original state
   // frame of reference based on orientation quaternion
   memcpy(v, vReal, sizeof(VectorInt16));
   v -> rotate(q);
   return 0;
}
// uint8_t MPU6050::dmpGetGyroAndAccelSensor(long data, const uint8_t packet);
// uint8_t MPU6050::dmpGetGyroSensor(long data, const uint8_t packet);
// uint8_t MPU6050::dmpGetControlData(long data, const uint8_t packet);
// uint8_t MPU6050::dmpGetTemperature(long data, const uint8_t packet);
// uint8_t MPU6050::dmpGetGravity(long data, const uint8_t packet);
uint8_t MPU6050::dmpGetGravity(VectorFloat v, Quaternion q) {
   v -> x = 2 * (q -> x
q -> z - q -> w
q -> y);
   v -> y = 2 * (q -> w
q -> x + q -> y
q -> z);
   v -> z = q -> w
q -> w - q -> xq -> x - q -> yq -> y + q -> z*q -> z;
   return 0;
}
// uint8_t MPU6050::dmpGetUnquantizedAccel(long data, const uint8_t packet);
// uint8_t MPU6050::dmpGetQuantizedAccel(long data, const uint8_t packet);
// uint8_t MPU6050::dmpGetExternalSensorData(long data, int size, const uint8_t packet);
// uint8_t MPU6050::dmpGetEIS(long data, const uint8_t packet);

uint8_t MPU6050::dmpGetEuler(float data, Quaternion q) {
   data[0] = atan2(2
q -> x
q -> y - 2q -> wq -> z, 2q -> wq -> w + 2q -> xq -> x - 1);   // psi
   data[1] = -asin(2q -> xq -> z + 2q -> wq -> y);                              // theta
   data[2] = atan2(2q -> yq -> z - 2q -> wq -> x, 2q -> wq -> w + 2q -> zq -> z - 1);   // phi
   return 0;
}
uint8_t MPU6050::dmpGetYawPitchRoll(float data, Quaternion q, VectorFloat gravity) {
   // yaw: (about Z axis)
   data[0] = atan2(2
q -> x
q -> y - 2
q -> wq -> z, 2q -> wq -> w + 2q -> xq -> x - 1);
   // pitch: (nose up/down, about Y axis)
   data[1] = atan(gravity -> x / sqrt(gravity -> y
gravity -> y + gravity -> zgravity -> z));
   // roll: (tilt left/right, about X axis)
   data[2] = atan(gravity -> y / sqrt(gravity -> x
gravity -> x + gravity -> z*gravity -> z));
   return 0;
}

How Do I add this part just to read Degrees I don't quite understand how you call the function ?

Degrees = (radians * 180.0 / M_PI);

I have it all working and it seem to measure 45 degree angle good but when I measure 90 degree my inclinometer read 89.69 and on the mpu6050 the display reads 91.67 degrees, I ran the calibration to get the offsets. I would like to get it closer to the real inclinometer

Hello zhomeslice,

your code "MPU6050_Latest_code" works fine and is very usefull for my project. Thanks for that.

My problem is that the roll angle is changing his value to a certain value also when I dont move this angle.
For example when I reset the values to zero in python, only the roll angle is immediatly starting to increase or decrease his value to for example +/-5°.
I have already checked that the problem is not my python code, I can see the same problem in the serial monitor in arduino IDE.

Interestingly, I dont have this problem with the pitch angle or the yaw angle.
Since I believe both angles (roll, pitch) get their information also from the accelerometer, the accelerometervalues are not the problem.

Do you or someone else have any idea how to solve this problem?

Thanks

oil1:
Hello zhomeslice,

your code "MPU6050_Latest_code" works fine and is very usefull for my project. Thanks for that.

My problem is that the roll angle is changing his value to a certain value also when I dont move this angle.
For example when I reset the values to zero in python, only the roll angle is immediatly starting to increase or decrease his value to for example +/-5°.
I have already checked that the problem is not my python code, I can see the same problem in the serial monitor in arduino IDE.

Interestingly, I dont have this problem with the pitch angle or the yaw angle.
Since I believe both angles (roll, pitch) get their information also from the accelerometer, the accelerometervalues are not the problem.

Do you or someone else have any idea how to solve this problem?

Thanks

The Roll is directly controlled by the accelerometer. The latest version of my Simple_MPU6050 library has an improved calibration routine. 1st it will continue calibrating until it achieves correct values. and second, it is even faster.
I am also updating Jeff Roberg's MPU6050 library with the latest calibration routine and added many of the enhancements I've been working on including DMP V6.12

When the NEW Calibration routine triggers, be sure that gravity is only influencing the z-axis of the accelerometer. any tilt to the MPU will cause the calculations to shift to one or both axis which will affect pitch and roll. my calibration code removes gravity from the z access and then attempts to make all accelerometer values zero using PID to loop through test after test until it meets my minimums or max readings are achieved.
Z
Check back later today to see if I resolved a setting issue I've discovered. go to Github: Simple_MPU6050

Hi zhomeslice,
thanks for your fast reply.

When Im running your code example "Simple_MPU6050_Example" on Arduino IDE Im getting this error:

Arduino: 1.6.9 (Windows 7), Board: "Arduino/Genuino Uno"

In file included from C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/Simple_MPU6050.h:5:0,

                 from C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master\Examples\Simple_MPU6050_Example\Simple_MPU6050_Example.ino:3:

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:530:27: error: ISO C++ forbids declaration of 'normalize' with no type [-fpermissive]

   Quaternion :: normalize() {

                           ^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:530:3: error: extra qualification 'Quaternion::' on member 'normalize' [-fpermissive]

   Quaternion :: normalize() {

   ^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: In member function 'int Quaternion::normalize()':

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:536:12: error: invalid conversion from 'Quaternion* const' to 'int' [-fpermissive]

     return this;

            ^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: At global scope:

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:569:28: error: ISO C++ forbids declaration of 'normalize' with no type [-fpermissive]

   VectorInt16 :: normalize() {

                            ^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:569:3: error: extra qualification 'VectorInt16::' on member 'normalize' [-fpermissive]

   VectorInt16 :: normalize() {

   ^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:583:38: error: ISO C++ forbids declaration of 'rotate' with no type [-fpermissive]

   VectorInt16 :: rotate(Quaternion *q) {

                                      ^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:583:3: error: extra qualification 'VectorInt16::' on member 'rotate' [-fpermissive]

   VectorInt16 :: rotate(Quaternion *q) {

   ^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: In member function 'int VectorInt16::normalize()':

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:574:12: error: invalid conversion from 'VectorInt16* const' to 'int' [-fpermissive]

     return this;

            ^

In file included from C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/Simple_MPU6050.h:5:0,

                 from C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master\Examples\Simple_MPU6050_Example\Simple_MPU6050_Example.ino:3:

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: In member function 'int VectorInt16::rotate(Quaternion*)':

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:606:12: error: invalid conversion from 'VectorInt16* const' to 'int' [-fpermissive]

     return this;

            ^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: At global scope:

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:638:28: error: ISO C++ forbids declaration of 'normalize' with no type [-fpermissive]

   VectorFloat :: normalize() {

                            ^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:638:3: error: extra qualification 'VectorFloat::' on member 'normalize' [-fpermissive]

   VectorFloat :: normalize() {

   ^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:652:38: error: ISO C++ forbids declaration of 'rotate' with no type [-fpermissive]

   VectorFloat :: rotate(Quaternion *q) {

                                      ^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:652:3: error: extra qualification 'VectorFloat::' on member 'rotate' [-fpermissive]

   VectorFloat :: rotate(Quaternion *q) {

   ^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: In member function 'int VectorFloat::normalize()':

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:643:12: error: invalid conversion from 'VectorFloat* const' to 'int' [-fpermissive]

     return this;

            ^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: In member function 'int VectorFloat::rotate(Quaternion*)':

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:665:12: error: invalid conversion from 'VectorFloat* const' to 'int' [-fpermissive]

     return this;

            ^

exit status 1
Fehler beim Kompilieren für das Board Arduino/Genuino Uno.

Sorry beginner
Thanks for your help!

oil1:
Hi zhomeslice,
thanks for your fast reply.

When Im running your code example "Simple_MPU6050_Example" on Arduino IDE Im getting this error:

Arduino: 1.6.9 (Windows 7), Board: "Arduino/Genuino Uno"

In file included from C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/Simple_MPU6050.h:5:0,

from C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master\Examples\Simple_MPU6050_Example\Simple_MPU6050_Example.ino:3:

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:530:27: error: ISO C++ forbids declaration of 'normalize' with no type [-fpermissive]

Quaternion :: normalize() {

^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:530:3: error: extra qualification 'Quaternion::' on member 'normalize' [-fpermissive]

Quaternion :: normalize() {

^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: In member function 'int Quaternion::normalize()':

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:536:12: error: invalid conversion from 'Quaternion* const' to 'int' [-fpermissive]

return this;

^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: At global scope:

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:569:28: error: ISO C++ forbids declaration of 'normalize' with no type [-fpermissive]

VectorInt16 :: normalize() {

^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:569:3: error: extra qualification 'VectorInt16::' on member 'normalize' [-fpermissive]

VectorInt16 :: normalize() {

^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:583:38: error: ISO C++ forbids declaration of 'rotate' with no type [-fpermissive]

VectorInt16 :: rotate(Quaternion *q) {

^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:583:3: error: extra qualification 'VectorInt16::' on member 'rotate' [-fpermissive]

VectorInt16 :: rotate(Quaternion *q) {

^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: In member function 'int VectorInt16::normalize()':

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:574:12: error: invalid conversion from 'VectorInt16* const' to 'int' [-fpermissive]

return this;

^

In file included from C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/Simple_MPU6050.h:5:0,

from C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master\Examples\Simple_MPU6050_Example\Simple_MPU6050_Example.ino:3:

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: In member function 'int VectorInt16::rotate(Quaternion*)':

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:606:12: error: invalid conversion from 'VectorInt16* const' to 'int' [-fpermissive]

return this;

^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: At global scope:

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:638:28: error: ISO C++ forbids declaration of 'normalize' with no type [-fpermissive]

VectorFloat :: normalize() {

^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:638:3: error: extra qualification 'VectorFloat::' on member 'normalize' [-fpermissive]

VectorFloat :: normalize() {

^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:652:38: error: ISO C++ forbids declaration of 'rotate' with no type [-fpermissive]

VectorFloat :: rotate(Quaternion *q) {

^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:652:3: error: extra qualification 'VectorFloat::' on member 'rotate' [-fpermissive]

VectorFloat :: rotate(Quaternion *q) {

^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: In member function 'int VectorFloat::normalize()':

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:643:12: error: invalid conversion from 'VectorFloat* const' to 'int' [-fpermissive]

return this;

^

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h: In member function 'int VectorFloat::rotate(Quaternion*)':

C:\Users\Tobias\Documents\Arduino\libraries\Simple_MPU6050-master/DMP_Image.h:665:12: error: invalid conversion from 'VectorFloat* const' to 'int' [-fpermissive]

return this;

^

exit status 1
Fehler beim Kompilieren für das Board Arduino/Genuino Uno.





Sorry beginner
Thanks for your help!

While I rewrote most of the interface code to the MPU I didn't alter the Quaternion code as it is outside of my understanding. I don't get this error when I compile the code. I will try to look into it and see if there is a simple correction I can do.