If 12 factor calibration is used on both accelerometer and magnetometer data, and the Rodrigues formula is applied do the magnetic dip statistics improve?
Code to apply 12 factor calibrations ( Using a LSM9DS1 IMU )
//Use 12 element calibration on raw count magnetometer data
function cal8G(S){
var i;
var mm=[0,0,0];
var scale=8;
var mres=[
[0.970972836,0.171154738,-0.000344029],
[-0.095223453,0.956653319,-0.000125418],
[0.017179224,0.005190024,1],
];
var moff=[1057.176483,120.7727841,549.551664];
for(i=0;i<3;i++) S.m[i] -=moff[i];
for(i=0;i<3;i++)
mm[i]=S.m[0]*mres[i][0]+S.m[1]*mres[i][1]+S.m[2]*mres[i][2];
for(i=0;i<3;i++)S.m[i]=mm[i]*scale/32768;
}//end cal8G(S)
//Use 12 element calibration on raw count accelerometer data
function calA2(S){
var i;
var mm=[0,0,0];
var scale=2;
var mres=[
[1.005708319,-0.007635345,-1.55429E-05],
[0.001530038,1.006717582,-9.04159E-05],
[0.017299441,0.097632586,1]
];
var moff=[-126.0318135,-350.2409885,730.2274842];
for(i=0;i<3;i++) S.a[i] -=moff[i];
for(i=0;i<3;i++)
mm[i]=S.a[0]*mres[i][0]+S.a[1]*mres[i][1]+S.a[2]*mres[i][2];
for(i=0;i<3;i++)S.a[i]=mm[i]*scale/32768;
}//end cal8G(S)
////////////////////
function readall(W){
if(W.magAvailable()){
W.readMag();
W.readAccel();
cal8G(W);
calA2(W);
console.log(W.a,',',W.m);
//console.log(W.a);
}//endif
}//end readall
Data were collected and pasted into the following code that is used to determine the signs of the magnetometer axis that produce the best magnetic dip angle statistics.
function test(){
FF=require("Rodrigues").connect();
var i,j,k,l;
var d="";
var t=[0,0,0];
console.log("mmm,mmp,mpm,mpp,pmm,pmp,ppm,ppp");
for(i=0;i<Adata.length;i++){
d=" "+i;
A=FF.Setup(Adata[i],[0,0,1]);
Theta=FF.theta;
Kn=FF.Kn;
A=FF.An;
for(j=-1;j<2;j=j+2){
for(k=-1;k<2;k=k+2){
for(l=-1;l<2;l=l+2){
t[0]=Mdata[i][0]*j;
t[1]=Mdata[i][1]*k;
t[2]=Mdata[i][2]*l;
B=FF.RotVector(t);
An=FF.An;
dip=pirate*Math.atan(B[2]/Math.sqrt(B[0]*B[0]+B[1]*B[1]));
d=d+","+dip;
}//nextl
}//nextk
}//nextj
console.log(d);
}//next i
}
This produces output that looks like the following:
N
mmm
mmp
mpm
mpp
pmm
pmp
ppm
ppp
0
66.84
-65.86
63.19
-69.97
69.97
-63.19
65.86
-66.84
1
65.84
-67.25
63.43
-70.09
70.09
-63.43
67.25
-65.84
2
66.60
-64.70
61.16
-71.07
71.07
-61.16
64.70
-66.60
This output is copied into a CSV file and the CSV file is opened using Excel. Descriptive Statistics are then applied to the columns of data
Statistic
mmm
mmp
mpm
mpp
pmm
pmp
ppm
ppp
Mean
36.62
-58.66
22.56
-72.11
72.11
-22.56
58.66
-36.62
Standard Error
7
4.84
8.39
0.39
0.39
8.39
4.84
7
Median
65.64
-72.26
65.17
-72.21
72.21
-65.17
72.26
-65.64
Mode
#N/A
#N/A
#N/A
#N/A
#N/A
#N/A
#N/A
#N/A
Standard Deviation
58.16
40.16
69.67
3.27
3.27
69.67
40.16
58.16
Sample Variance
3382.36
1613.19
4853.89
10.67
10.67
4853.89
1613.19
3382.36
Kurtosis
-0.42
3.95
-1.6
0.78
0.78
-1.6
3.95
-0.42
Skewness
-1.16
2.31
-0.59
0.28
-0.28
0.59
-2.31
1.16
Range
177.14
150.05
169.77
14.85
14.85
169.77
150.05
177.14
Minimum
-88.87
-87.5
-81.07
-79.4
64.56
-88.7
-62.55
-88.27
Maximum
88.27
62.55
88.7
-64.56
79.4
81.07
87.5
88.87
Sum
2526.48
-4047.26
1556.98
-4975.74
4975.74
-1556.98
4047.26
-2526.48
Count
69
69
69
69
69
69
69
69
COV
159.00%
-68.00%
309.00%
-5.00%
5.00%
-309.00%
68.00%
-159.00%
The mpp and pmm columns produce the smallest coffoecoent of variation (COV) values. The following code uses the +X, -Y, -Z (pmm) combination.
function test(){
FF=require("Rodrigues").connect();
var i;
for(i=0;i<Adata.length;i++){
A=FF.Setup(Adata[i],[0,0,1]);
Theta=FF.theta;
Kn=FF.Kn;
A=FF.An;
t[0]=Mdata[i][0]*1;
t[1]=Mdata[i][1]*-1;
t[2]=Mdata[i][2]*-1;
B=FF.RotVector(t);
An=FF.An;
heading=pirate*Math.atan2(-B[1],B[0]);
if(heading<0)heading+=360;
dip=pirate*Math.atan(B[2]/Math.sqrt(B[0]*B[0]+B[1]*B[1]));
console.log(i,',',A,',',An,',',B,',',
Theta,',',heading,',',dip);
}//next i
}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
If 12 factor calibration is used on both accelerometer and magnetometer data, and the Rodrigues formula is applied do the magnetic dip statistics improve?
Code to apply 12 factor calibrations ( Using a LSM9DS1 IMU )
Data were collected and pasted into the following code that is used to determine the signs of the magnetometer axis that produce the best magnetic dip angle statistics.
This produces output that looks like the following:
This output is copied into a CSV file and the CSV file is opened using Excel. Descriptive Statistics are then applied to the columns of data
The mpp and pmm columns produce the smallest coffoecoent of variation (COV) values. The following code uses the +X, -Y, -Z (pmm) combination.
This produces the following: