@@ -44,7 +44,7 @@ class Gyroscope(InertialSensor):
4444 The cross axis sensitivity of the sensor in percentage.
4545 name : str
4646 The name of the sensor.
47- rotation_sensor_to_body : Matrix
47+ rotation_matrix : Matrix
4848 The rotation matrix of the sensor from the sensor frame to the rocket
4949 frame of reference.
5050 normal_vector : Vector
@@ -222,26 +222,33 @@ def measure(self, time, **kwargs):
222222 u_dot = kwargs ["u_dot" ]
223223 relative_position = kwargs ["relative_position" ]
224224
225- # Angular velocity of the rocket in the body frame
225+ # Angular velocity of the rocket in the rocket frame
226226 omega = Vector (u [10 :13 ])
227227
228228 # Transform to sensor frame
229- W = self ._total_rotation_sensor_to_body @ omega
229+ inertial_to_sensor = self ._total_rotation_matrix @ Matrix .transformation (
230+ u [6 :10 ]
231+ )
232+ W = inertial_to_sensor @ omega
230233
231234 # Apply noise + bias and quantize
232235 W = self .apply_noise (W )
233236 W = self .apply_temperature_drift (W )
234237
235238 # Apply acceleration sensitivity
236239 if self .acceleration_sensitivity != Vector .zeros ():
237- W += self .apply_acceleration_sensitivity (omega , u_dot , relative_position )
240+ W += self .apply_acceleration_sensitivity (
241+ omega , u_dot , relative_position , inertial_to_sensor
242+ )
238243
239244 W = self .quantize (W )
240245
241246 self .measurement = tuple ([* W ])
242247 self ._save_data ((time , * W ))
243248
244- def apply_acceleration_sensitivity (self , omega , u_dot , relative_position ):
249+ def apply_acceleration_sensitivity (
250+ self , omega , u_dot , relative_position , rotation_matrix
251+ ):
245252 """
246253 Apply acceleration sensitivity to the sensor measurement
247254
@@ -253,6 +260,8 @@ def apply_acceleration_sensitivity(self, omega, u_dot, relative_position):
253260 The time derivative of the state vector
254261 relative_position : Vector
255262 The vector from the rocket's center of mass to the sensor
263+ rotation_matrix : Matrix
264+ The rotation matrix from the rocket frame to the sensor frame
256265
257266 Returns
258267 -------
@@ -262,7 +271,7 @@ def apply_acceleration_sensitivity(self, omega, u_dot, relative_position):
262271 # Linear acceleration of rocket cdm in inertial frame
263272 inertial_acceleration = Vector (u_dot [3 :6 ])
264273
265- # Angular accel of rocket in body frame
274+ # Angular velocity and accel of rocket
266275 omega_dot = Vector (u_dot [10 :13 ])
267276
268277 # Acceleration felt in sensor
@@ -272,7 +281,7 @@ def apply_acceleration_sensitivity(self, omega, u_dot, relative_position):
272281 + Vector .cross (omega , Vector .cross (omega , relative_position ))
273282 )
274283 # Transform to sensor frame
275- A = self . _total_rotation_sensor_to_body @ A
284+ A = rotation_matrix @ A
276285
277286 return self .acceleration_sensitivity & A
278287
0 commit comments