def test_calibration_points_2_degrees(self): sc = StandardCalibration(verbose=True) sc.calibrate_gyroscope_with_stored_points( self.points_2_zero, self.test_points_2, sc.RECORD_PLAYER_33_3_RPM_IN_DPS) np.testing.assert_allclose(sc.gyro_bias_vector, np.array([-0.67834283, 0.79632176, 1.56510056]), rtol=1e-6, atol=1e-6) np.testing.assert_allclose(sc.gyro_scale_factor_vector, np.array([0.01698324, 0.01662334, 0.01690871]), rtol=1e-6, atol=1e-6)
def test_calibration_points_1_degrees(self): sc = StandardCalibration(verbose=True) sc.calibrate_gyroscope_with_stored_points( self.points_1_zero, self.test_points_1, sc.RECORD_PLAYER_45_RPM_IN_DPS) np.testing.assert_allclose(sc.gyro_bias_vector, np.array([-0.01581438, 0.01164529, 0.02771216]) * 57.2957795, rtol=1e-6, atol=1e-6) np.testing.assert_allclose(sc.gyro_scale_factor_vector, np.array([0.00030169, 0.00029362, 0.00029876]) * 57.2957795, rtol=1e-6, atol=1e-6)
def test_calibration_points_correspondence_with_datasheet_values(self): sc = StandardCalibration(verbose=True) sc2 = StandardCalibration(verbose=True) client, smbus, mockbus = create_device() client.open() client.bus._read = mockbus._written sc.calibrate_gyroscope_with_stored_points( self.points_2_zero, self.test_points_2, sc.RECORD_PLAYER_33_3_RPM_IN_DPS) sc2.set_datasheet_values_for_gyroscope(client.get_settings()) def _internal_test_function(untransformed_g, tolerance): np.testing.assert_allclose(sc.transform_gyroscope_values(untransformed_g), sc2.transform_gyroscope_values(untransformed_g - self.points_2_zero), atol=tolerance) for index in range(3): for side in [-1, 1]: k = index * 2 if side == -1 else (index * 2) + 1 ref = np.zeros((3,), 'float') ref[index] = sc.RECORD_PLAYER_33_3_RPM_IN_DPS * side yield _internal_test_function, self.test_points_2[k, :], 15.0