@@ -45,11 +45,14 @@ def test_accelerometer(self):
4545 """Test an ideal accelerometer."""
4646 accelerometer = self .flight .rocket .sensors [0 ].component
4747 time , ax , ay , az = zip (* accelerometer .measured_data [0 ])
48- a = np .sqrt (np .array (ax ) ** 2 + np .array (ay ) ** 2 + np .array (az ) ** 2 )
49- sim_accel = self .flight .acceleration (time )
48+ sim_ax = self .flight .ax_body_frame (time )
49+ sim_ay = self .flight .ay_body_frame (time )
50+ sim_az = self .flight .az_body_frame (time )
51+
52+ assert np .allclose (ax , sim_ax , atol = 1e-12 )
53+ assert np .allclose (ay , sim_ay , atol = 1e-12 )
54+ assert np .allclose (az , sim_az , atol = 1e-12 )
5055
51- # tolerance is bounded to numerical errors in the transformation matrixes
52- assert np .allclose (a , sim_accel , atol = 1e-12 )
5356 # check if both added accelerometer instances saved the same data
5457 assert (
5558 self .flight .sensors [0 ].measured_data [0 ]
@@ -60,12 +63,13 @@ def test_gyroscope(self):
6063 """Test an ideal gyroscope."""
6164 gyroscope = self .flight .rocket .sensors [2 ].component
6265 time , wx , wy , wz = zip (* gyroscope .measured_data )
63- w = np .sqrt (np .array (wx ) ** 2 + np .array (wy ) ** 2 + np .array (wz ) ** 2 )
64- flight_wx = np .array (self .flight .w1 (time ))
65- flight_wy = np .array (self .flight .w2 (time ))
66- flight_wz = np .array (self .flight .w3 (time ))
67- sim_w = np .sqrt (flight_wx ** 2 + flight_wy ** 2 + flight_wz ** 2 )
68- assert np .allclose (w , sim_w , atol = 1e-12 )
66+ sim_wx = self .flight .w1 (time )
67+ sim_wy = self .flight .w2 (time )
68+ sim_wz = self .flight .w3 (time )
69+
70+ assert np .allclose (wx , sim_wx , atol = 1e-12 )
71+ assert np .allclose (wy , sim_wy , atol = 1e-12 )
72+ assert np .allclose (wz , sim_wz , atol = 1e-12 )
6973
7074 def test_barometer (self ):
7175 """Test an ideal barometer."""
0 commit comments