Skip to content

Commit

Permalink
Add tests for return of rotation matrices in estimator Tilt.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayitzin committed Oct 21, 2024
1 parent f5c2bed commit fcaaf4b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_estimators.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,10 @@ def test_acc_mag(self):
orientation = ahrs.QuaternionArray(ahrs.filters.Tilt(acc=self.accelerometers, mag=self.magnetometers).Q)
self.assertLess(np.nanmean(ahrs.utils.metrics.qad(REFERENCE_QUATERNIONS, orientation)), THRESHOLD)

def test_acc_mag_return_rotmat(self):
tilt = ahrs.filters.Tilt(acc=SENSOR_DATA.accelerometers, mag=SENSOR_DATA.magnetometers, representation='rotmat')
self.assertLess(np.nanmean(ahrs.utils.metrics.chordal(REFERENCE_ROTATIONS, tilt.Q)), THRESHOLD)

def test_acc_only(self):
sensors = ahrs.Sensors(num_samples=1000, in_degrees=False, yaw=0.0, span=(-np.pi/2, np.pi/2))
tilt = ahrs.filters.Tilt(acc=sensors.accelerometers)
Expand All @@ -801,6 +805,11 @@ def test_acc_only_return_angles(self):
self.assertLess(np.nanmean(ahrs.utils.metrics.rmse(sensors.ang_pos, tilt.Q)), THRESHOLD)
self.assertLess(np.nanmean(ahrs.utils.metrics.rmse(sensors.ang_pos, tilt.angles)), THRESHOLD)

def test_acc_only_return_rotmat(self):
sensors = ahrs.Sensors(num_samples=1000, in_degrees=False, yaw=0.0, span=(-np.pi/2, np.pi/2))
tilt = ahrs.filters.Tilt(acc=sensors.accelerometers, representation='rotmat')
self.assertLess(np.nanmean(ahrs.utils.metrics.chordal(sensors.rotations, tilt.Q)), THRESHOLD)

def test_wrong_input_vectors(self):
self.assertRaises(TypeError, ahrs.filters.Tilt, acc=1.0)
self.assertRaises(TypeError, ahrs.filters.Tilt, acc="self.accelerometers")
Expand Down

0 comments on commit fcaaf4b

Please sign in to comment.