1 /* Copyright (C) 2008 Sean D'Epagnier <sean@depagnier.com>
3 * This Program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public
5 * License as published by the Free Software Foundation; either
6 * version 3 of the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 * For more information on the GPL, please go to:
18 * http://www.gnu.org/copyleft/gpl.html
24 #include <calibration/calibrationserver.h>
25 #include <calibration/calc.h>
27 #include <linalg/vector.h>
31 int main(int argc
, char *argv
[])
39 magX
[0] = 1.0 / 50100;
59 #if 0 /* s (d and r) */
75 magX
[0] = 1.0 / 50400;
107 magalignX
[0] = 0.0020;
108 magalignX
[1] = 0.000453;
109 magalignX
[2] = 0.0384;
113 accellaseralignment
[1] = 0.00;
114 accellaseralignment
[2] = -0.013;
115 accellaseralignment
[3] = -.01;
117 accellaseralignment
[0] = sqrt(1 - magnitude2(accellaseralignment
+1));
118 memcpy(maglaseralignment
, accellaseralignment
, sizeof accellaseralignment
);
120 float corrazimuth
= 0, total
=0, totalm
=0;
122 static float asave
[72];
124 while(fgets(buffer
, sizeof buffer
, stdin
)) {
125 if(sscanf(buffer
, "rawaccel: %ld %ld %ld\n",
128 accel
.filtered
+ 2) == 3) {
131 accel
.filtered
[i
] <<= 4;
134 if(sscanf(buffer
, "rawmag: %ld %ld %ld\n",
137 mag
.filtered
+ 2) == 3) {
139 calc_laser_incline_azimuth();
142 calc_get_calibrated_accel(a
);
144 float diff
= azimuth
- corrazimuth
;
150 float m
= 1-calibration_get_mag_magnitude();
166 float d
= asave
[j
] - total
/ i
;
168 printf("%.2f %.2f %.2f\n", corrazimuth
, d
, asave
[j
]);
179 fprintf(stderr
, "mag dev: %.5f\n", sqrt(totalm
/ 72));
180 fprintf(stderr
, "dev: %.5f\n", sqrt(dev
/ 72));