From 7f6244f337626b60bbf430452fd79a9fc411353a Mon Sep 17 00:00:00 2001 From: Markus Koller Date: Mon, 30 Jan 2023 14:15:43 +0100 Subject: [PATCH] BUG: Calibration routine uses raw field instead of compensated field Substracting the ambient field from the set magnetic field values during calibration, no longer substract initial offset measurement from all readings --- src/calibration.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibration.py b/src/calibration.py index de37766..6731b16 100644 --- a/src/calibration.py +++ b/src/calibration.py @@ -476,14 +476,15 @@ class MagnetometerCalibrationComplete(Thread): for vec_idx, test_vec in enumerate(test_vectors): # Command output applied_vec = test_vec * self.calibration_mag_field - self.cage_dev.set_field_raw(applied_vec) + self.cage_dev.set_field_compensated(applied_vec) # Set compensated field not raw field # Sleep for a certain duration to allow psu to stabilize output and magnetometer to supply readings time.sleep(self.calibration_interval) # Read output and save to array for solver later raw_reading = g.MAGNETOMETER.field - reading = raw_reading - offsets + # reading = raw_reading - offsets + reading = raw_reading # Do not substract offset since it will artificially suppress (hard-iron) offsets for i in range(3): row = {'m': reading[i], 'b_x': applied_vec[0], 'b_y': applied_vec[1], 'b_z': applied_vec[2]} # self.put_message("[Axis {}] {}".format(i, row))