49 rvector magfield, magref, magdiff, stablemagfield,magCF,rod_F;
51 float magdiffX,magdiffY,magdiffZ;
52 float stablemagfieldX,stablemagfieldY,stablemagfieldZ;
53 float roll, pitch, yaw;
65 ofstream imu_lastdatapoint;
70 imu_logfile.open (
"imu_log.dat", fstream::in | fstream::out |
fstream::app);
75 iretn = microstrain_connect(
"/dev/ttyOS3");
79 printf(
"Error: microstrain_connect() %d\n",iretn);
85 iretn_mag = microstrain_magfield(handle, &magref);
89 imu_lastdatapoint.open (
"imu_lastdatapoint.dat",ios::trunc);
91 iretn = microstrain_euler_angles(handle, &euler);
95 magX = magfield.
col[0];
96 magY = magfield.
col[1];
97 magZ = magfield.
col[2];
108 iretn_mag = microstrain_magfield(handle, &magfield);
109 iretn_mag = microstrain_stab_accel_rate_magfield(handle,&accel,&rate,&stablemagfield);
112 stablemagfieldX = stablemagfield.
col[0];
113 stablemagfieldY = stablemagfield.
col[1];
114 stablemagfieldZ = stablemagfield.
col[2];
116 magdiff =
rv_sub(stablemagfield,magfield);
118 magdiffX = magdiff.
col[0];
119 magdiffY = magdiff.
col[1];
120 magdiffZ = magdiff.
col[2];
123 printf(
"%d: %' '3.2f %' '3.2f %' '3.2f | ",i, roll,pitch,yaw);
124 printf(
"%' '3.5f %' '3.5f %' '3.5f | ", magX,magY,magZ);
125 printf(
"%' '3.2f %' '3.2f %' '3.2f | ", magdiffX,magdiffY,magdiffZ,
length_rv(magfield));
126 printf(
"%' '3.2f %' '3.2f %' '3.2f |%f ||", stablemagfieldX,stablemagfieldY,stablemagfieldZ,
length_rv(stablemagfield));
128 printf(
"%' '3.2f %' '3.2f %' '3.2f | %f \n", magCF.
col[0],magCF.
col[0],magCF.
col[0],
length_rv(magCF));
131 imu_lastdatapoint << i <<
"," << roll <<
"," << pitch <<
"," << yaw <<
"\n";
133 imu_lastdatapoint.close();
146 iretn = microstrain_disconnect(handle);
3 element generic row vector
Definition: vector.h:53
int i
Definition: rw_test.cpp:37
double length_rv(rvector v)
Length of row vector.
Definition: vector.cpp:748
int iretn
Definition: rw_test.cpp:37
app
Definition: imu_stream_plot.py:339
double e
Elevation.
Definition: vector.h:282
double b
Bank.
Definition: vector.h:284
3 element attitude vector.
Definition: vector.h:277
#define DEGOF(rad)
Degrees of a Radian value.
Definition: math/constants.h:33
int32_t cssl_stop()
Definition: cssl_lib.cpp:86
gige_handle * handle
Definition: kpc9612p_recv.cpp:33
double col[3]
Definition: vector.h:55
double h
Heading.
Definition: vector.h:280
rvector rv_sub(rvector a, rvector b)
Subtract two vectors.
Definition: vector.cpp:315
rvector rv_cross(rvector a, rvector b)
Take cross product of two row vectors.
Definition: vector.cpp:363