Skip to content

Commit 420db89

Browse files
Reverted IMUMonitor.cpp to prior version to remove print statements
1 parent 8bd88bd commit 420db89

File tree

1 file changed

+9
-56
lines changed

1 file changed

+9
-56
lines changed

src/Monitors/IMUMonitor.cpp

Lines changed: 9 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,6 @@ void IMUMonitor::imu_offset()
239239
if (!sfr::imu::gyro_z_value->get_value(&gyro_z)) {
240240
gyro_z = 0;
241241
}
242-
Serial.println("Raw IMU Data:");
243-
Serial.print("Mag X: "); Serial.println(mag_x);
244-
Serial.print("Mag Y: "); Serial.println(mag_y);
245-
Serial.print("Mag Z: "); Serial.println(mag_z);
246-
Serial.print("Gyro X: "); Serial.println(gyro_x);
247-
Serial.print("Gyro Y: "); Serial.println(gyro_y);
248-
Serial.print("Gyro Z: "); Serial.println(gyro_z);
249-
Serial.println("----------");
250242

251243
/*Offset Contributions from PWM (ex: pwmX_oX is contribution of X mag to offset x)*/
252244
float pwmX_ox, pwmX_oy, pwmX_oz;
@@ -273,51 +265,21 @@ void IMUMonitor::imu_offset()
273265
float temp_z = (0.206) * temp_imu.temperature + (-6.835);
274266
/*******************************************/
275267
/*Total Offsets*/
276-
277268
float mag_xoffset = (pwmX_ox + pwmY_ox + pwmZ_ox) * Volt_c + temp_x + hardiron_x;// rewrite
278269
float mag_yoffset = (pwmX_oy + pwmY_oy + pwmZ_oy) * Volt_c + temp_y + hardiron_y;
279270
float mag_zoffset = (pwmX_oz + pwmY_oz + pwmZ_oz) * Volt_c + temp_z + hardiron_z;// rewrite this
280271

281-
Serial.println("Hard Iron Components: ");
282-
Serial.print("Mag X: "); Serial.println(hardiron_x);
283-
Serial.print("Mag Y: "); Serial.println(hardiron_y);
284-
Serial.print("Mag Z: "); Serial.println(hardiron_z);
285-
Serial.println("________");
286-
287272
/*******************************************/
288273
/* Finally, adjust magnetometer/gyro readings*/
289-
// Serial.println("Unfiltered:");
290-
// Serial.print("Mag X: "); Serial.println(mag_x);
291-
// Serial.print("Mag Y: "); Serial.println(mag_y);
292-
// Serial.print("Mag Z: "); Serial.println(mag_z);
293-
294-
// Serial.print("Gyro X: "); Serial.println(gyro_x);
295-
// Serial.print("Gyro Y: "); Serial.println(gyro_y);
296-
// Serial.print("Gyro Z: "); Serial.println(gyro_z);
297-
float mag_x_corrected = mag_x - mag_xoffset;
298-
float mag_y_corrected = mag_y - mag_yoffset;
299-
float mag_z_corrected = mag_z - mag_zoffset;
300-
301-
float gyro_x_corrected = -(gyro_x - (-0.02297));
302-
float gyro_y_corrected = gyro_y - (0.03015);
303-
float gyro_z_corrected = gyro_z - (-0.01396);
304-
305-
sfr::imu::mag_x_value->set_value(mag_x_corrected);
306-
sfr::imu::mag_y_value->set_value(mag_y_corrected);
307-
sfr::imu::mag_z_value->set_value(mag_z_corrected);
308-
309-
sfr::imu::gyro_x_value->set_value(gyro_x_corrected);
310-
sfr::imu::gyro_y_value->set_value(gyro_y_corrected);
311-
sfr::imu::gyro_z_value->set_value(gyro_z_corrected);
312-
Serial.println("Soft-Iron Filtered: ");
313-
Serial.print("Mag X: "); Serial.println(mag_x_corrected);
314-
Serial.print("Mag Y: "); Serial.println(mag_y_corrected);
315-
Serial.print("Mag Z: "); Serial.println(mag_z_corrected);
316-
317-
Serial.print("Gyro X: "); Serial.println(gyro_x_corrected);
318-
Serial.print("Gyro Y: "); Serial.println(gyro_y_corrected);
319-
Serial.print("Gyro Z: "); Serial.println(gyro_z_corrected);
320-
Serial.print("_________");
274+
275+
sfr::imu::mag_x_value->set_value(mag_x - mag_xoffset);
276+
sfr::imu::mag_y_value->set_value(mag_y - mag_yoffset);
277+
sfr::imu::mag_z_value->set_value(mag_z - mag_zoffset);
278+
279+
// make gyro aligh with mag coor
280+
sfr::imu::gyro_x_value->set_value(-(gyro_x - (-0.02297)));
281+
sfr::imu::gyro_y_value->set_value(gyro_y - (0.03015));
282+
sfr::imu::gyro_z_value->set_value(gyro_z - (-0.01396));
321283
}
322284

323285
// generate a normal random variable using Box-Muller transform
@@ -489,15 +451,6 @@ void IMUMonitor::capture_imu_values()
489451
Serial.println(ekfObj.state(5));
490452
#endif
491453
// update the EKFed values
492-
Serial.println("EKF Filtered:");
493-
Serial.print("Mag X: "); Serial.println(ekfObj.state(0));
494-
Serial.print("Mag Y: ");Serial.println(ekfObj.state(1));
495-
Serial.print("Mag Z: "); Serial.println(ekfObj.state(2));
496-
Serial.print("Gyro X: "); Serial.println(ekfObj.state(3));
497-
Serial.print("Gyro Y: "); Serial.println(ekfObj.state(4));
498-
Serial.print("Gyro Z: "); Serial.println(ekfObj.state(5));
499-
Serial.println("_______");
500-
501454
sfr::imu::mag_x_value->set_value(ekfObj.state(0));
502455
sfr::imu::mag_y_value->set_value(ekfObj.state(1));
503456
sfr::imu::mag_z_value->set_value(ekfObj.state(2));

0 commit comments

Comments
 (0)