To correct the yaw problem change this line
if (loopCount == 40){//attempt full update at 10hz
compass.read();
gyro.read();
AHRSupdate(&G_Dt);
loopCount = 0;
}
To this:
if (loopCount == 32){//attempt full update at 10hz
compass.read();
gyro.read();
AHRSupdate(&G_Dt);
loopCount = 0;
}
I have updated the code in github. If you get unsatisfactory results or the system is taking up too much time the frequency of the updates can easily be changed by adjusting the loopCount comparisons. Thanks for your interest in the openIMU. I am working on porting the code to the razor 9dof board from sparkfun. Sorry for the slow reply. I now am being notified when a reply to this thread is made and I will be better at staying on to of my responses.
If that doesn't work try this:
void loop(){
compass.read();
gyro.read();
G_Dt = (micros() - timer)/1000000.0;
timer=micros();
AHRSupdate(&G_Dt);
if (millis() - printTimer > 50){
printTimer = millis();
GetEuler();
Serial.print(printTimer);
Serial.print(",");
Serial.print(pitch);
Serial.print(",");
Serial.print(roll);
Serial.print(",");
Serial.println(yaw);
}
}
It will run the full update at the maximum rate possible. Please let me know how this works out for you.