From 998b325ca9ddade526e81e19716bfb22bfdd8b49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Teichr=C3=B6b?= Date: Wed, 17 Aug 2022 15:28:33 +0200 Subject: [PATCH] Some fixes --- src/calibration.py | 7 ++++--- src/user_interface.py | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/calibration.py b/src/calibration.py index cdd0f29..84f88ac 100644 --- a/src/calibration.py +++ b/src/calibration.py @@ -238,7 +238,7 @@ class CoilConstantCalibration(Thread): class MagnetometerCalibration(Thread): TEST_VECTOR_MAGNITUDE = 100e-6 # In Tesla. Chosen so it can be achieved with a 3A PSU. - def __init__(self, view_queue, calibration_points, calibration_interval,mgm_to_helmholtz_cos_trans): + def __init__(self, view_queue, calibration_points, calibration_interval, mgm_to_helmholtz_cos_trans): Thread.__init__(self) self.view_queue = view_queue self.calibration_points = calibration_points @@ -283,8 +283,9 @@ class MagnetometerCalibration(Thread): self.cage_dev.set_field_compensated([0, 0, 0]) # Sleep for a certain duration to allow psu to stabilize output and magnetometer to supply readings time.sleep(self.calibration_interval) + matrix_trans_mgm_to_hh_np = np.array(self.matrix_trans_mgm_to_hh) # The offsets can easily be read from the magnetometer - offsets = self.matrix_trans_mgm_to_hh.dot(g.MAGNETOMETER.field) + offsets = matrix_trans_mgm_to_hh_np.dot(g.MAGNETOMETER.field) # Save data point to raw_data list raw_data.append({'applied_x': 0, 'applied_y': 0, 'applied_z': 0, 'measured_x': offsets[0], 'measured_y': offsets[1], 'measured_z': offsets[2]}) @@ -308,7 +309,7 @@ class MagnetometerCalibration(Thread): time.sleep(self.calibration_interval) # Read output and save to array for solver later - raw_reading = self.matrix_trans_mgm_to_hh.dot(g.MAGNETOMETER.field) + raw_reading = matrix_trans_mgm_to_hh_np.dot(g.MAGNETOMETER.field) reading = raw_reading - 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]} diff --git a/src/user_interface.py b/src/user_interface.py index a9dcfff..9f54389 100644 --- a/src/user_interface.py +++ b/src/user_interface.py @@ -1281,7 +1281,7 @@ class CalibrateMagnetometer(Frame): # Enable save buttons self.export_calibration_button.configure(state="normal") self.copy_calibration_button.configure(state="normal") - self.export_mgm_button.configure(state="normal") + # self.export_mgm_button.configure(state="normal") def start_calibration_procedure(self): try: @@ -1289,7 +1289,8 @@ class CalibrateMagnetometer(Frame): calibration_interval = self.calibration_interval_var.get() self.calibration_thread = MagnetometerCalibration(self.view_mpi_queue, calibration_points, - calibration_interval) + calibration_interval, + self.mgm_to_helmholtz_cos_trans) self.calibration_thread.start() self.deactivate_buttons() except (DeviceAccessError, TclError) as e: