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
This commit is contained in:
2023-01-30 14:15:43 +01:00
parent 85cad05b6e
commit 7f6244f337
+3 -2
View File
@@ -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))