After compiling the example almost as is (I2C instead of SPI on T32) I just wonder what is going on. Reaction is fast but after some wild movements it takes minutes till the values come in the region of zero. In pitch and roll the error can easily be 50 degrees right after the movements. The funny thing is that further wild movements sometimes lead to a correction.
I initially thought that the axes don't match. But the change for roll, pitch and yaw corresponds with the movement of the sensor.
// setting the accelerometer covariance
Filter.setAccelCovariance(0.001f);
// setting a 41 Hz DLPF bandwidth
Imu.setDlpfBandwidth(MPU9250::DLPF_BANDWIDTH_41HZ);
// setting SRD to 9 for a 100 Hz update rate
Imu.setSrd(9);
// enabling the data ready interrupt
Imu.enableDataReadyInterrupt();
// attaching the interrupt to microcontroller pin 1
pinMode(1,INPUT);
attachInterrupt(1,runFilter,RISING);
I'm not sure I'm getting a solid calibration with the uNavAHRS calibration sketch. Sorry if this is a dumb question, but is this roughly what you all are doing during calibration?
Accel Calibration:
1. Lay breadboard flat
2. (switch) Lay breadboard on left side
3. (switch) Lay breadboard on right side
4. (switch) Lay breadboard nose down
5. (switch) Lay breadboard nose up
6. (switch) Lay breadboard upside down
... accel calibration complete...
For Mag Calibration
1. Lay breadboard flat, move in figure 8 for ~5s
2. Lay breadboard on left side, move in figure 8 for ~5s
3. Lay breadboard on right side, move in figure 8 for ~5s
4. Lay breadboard nose down, move in figure 8 for ~5s
5. Lay breadboard nose up, move in figure 8 for ~5s
6. Lay breadboard upside down, move in figure 8 for ~5s
... mag calibration complete...
I'll try it outside next to make absolutely sure I'm away from anything metal.
Thx!
The mag is a little different: https://lh3.googleusercontent.com/el...6Kmd234n4=w350, but I do it the same way as you and get pretty good results.o calibrate them, call the calibrateAccel function 6 times, once for each orientation of the IMU (+X, -X, +Y, -Y, +Z, -Z) facing up.
Hi Brian. I was looking at the calibration code for the accelerometer but it looks like you are calibrating the accelerometer at 2g and then resetting the accelerometer range back to whatever range was selected by the user. Shouldn't you be calibrating at your selected range? Think you do the same for the gyro? I always did the cal's at the range I selected.
Also, can you confirm that the default settings are 16g for the accel and 2000 dps for the gyro?
Thanks
Mike
+++++++++++++++++
// scaling of quertonian,||q||^2 = 1
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
for(size_t i=0; i < 4; i++) {
xs(i,0) = xs(i,0)*1.0/sqrtf(xs(0,0)*xs(0,0)+xs(1,0)*xs(1,0)+xs(2,0)*xs(2,0)+xs(3,0)*xs(3,0));
}
double ux, uy, uz;
double rax, ray, raz;
float accelwog;
ux = 2 * (xs(1,0) * xs(3,0) - xs(0,0) * xs(2,0));
uy = 2 * (xs(2,0) * xs(3,0) + xs(0,0) * xs(1,0));
uz = 2 * (xs(0,0) * xs(0,0) + xs(3,0) * xs(3,0)) -1;
rax = ax/G + ux;
ray = ay/G + uy;
raz = az/G + uz;
accelwog = (float)(ux * rax + uy * ray + uz * raz)*G ;
// obtain euler angles from quaternion
theta = asinf(-2*(xs(1,0)*xs(3,0)-xs(0,0)*xs(2,0)));
phi = atan2f(2*(xs(0,0)*xs(1,0)+xs(2,0)*xs(3,0)),1-2*(xs(1,0)*xs(1,0)+xs(2,0)*xs(2,0)));
psi = atan2f(2*(xs(1,0)*xs(2,0)+xs(0,0)*xs(3,0)),1-2*(xs(2,0)*xs(2,0)+xs(3,0)*xs(3,0)));
_magCount++;
}
}
Brian, I loaded up my sketch that allows me to output to a ellipsoid model for accel and magnetometer calibration. I ran a test for 2g/250dps and 16g/2000dps. As could be expected the magnetometer was exactly the same but the accels were slightly different. First the obligatory screen shots for both cases:
1. 2g/250dps (first pic is uncalibrated and the second is calibrated):
View attachment 12451View attachment 12452
2. 16g/2000dps
View attachment 12453View attachment 12454
Can't really tell much from the pictures. Except that the accel has very little offset and the scale factors should be relatively close to 1 (if you normalize). Anyway. If you put it in a spreadsheet and apply the correct scale factors and multipyly by G (like you do), there are differences, may be small but previous experience with Madgwick and Mahoney, probably enough to cause some drift at some point. Heres the table, sorry for the screen shot but not sure how to insert table here:
View attachment 12455
Maybe this will help in your calibration decision.
Mike