8000 DEV: undo commits to develop · RocketPy-Team/RocketPy@9eaabb0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9eaabb0

Browse files
committed
DEV: undo commits to develop
1 parent d43a06b commit 9eaabb0

File tree

7 files changed

+237
-184
lines changed

7 files changed

+237
-184
lines changed

rocketpy/prints/sensors_prints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def orientation(self):
7474
self._print_aligned("Orientation:", self.sensor.orientation)
7575
self._print_aligned("Normal Vector:", self.sensor.normal_vector)
7676
print("Rotation Matrix:")
77-
for row in self.sensor.rotation_matrix:
77+
for row in self.sensor.rotation_sensor_to_body:
7878
value = " ".join(f"{val:.2f}" for val in row)
7979
value = [float(val) for val in value.split()]
8080
self._print_aligned("", value)

rocketpy/sensors/accelerometer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Accelerometer(InertialSensor):
4444
The cross axis sensitivity of the sensor in percentage.
4545
name : str
4646
The name of the sensor.
47-
rotation_matrix : Matrix
47+
rotation_sensor_to_body : Matrix
4848
The rotation matrix of the sensor from the sensor frame to the rocket
4949
frame of reference.
5050
normal_vector : Vector
@@ -241,8 +241,9 @@ def measure(self, time, **kwargs):
241241
+ Vector.cross(omega, Vector.cross(omega, r))
242242
)
243243
# Transform to sensor frame
244-
inertial_to_sensor = self._total_rotation_matrix @ Matrix.transformation(
245-
u[6:10]
244+
inertial_to_sensor = (
245+
self._total_rotation_sensor_to_body
246+
@ Matrix.transformation(u[6:10]).transpose
246247
)
247248
A = inertial_to_sensor @ A
248249

rocketpy/sensors/gyroscope.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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_matrix : Matrix
47+
rotation_sensor_to_body : Matrix
4848
The rotation matrix of the sensor from the sensor frame to the rocket
4949
frame of reference.
5050
normal_vector : Vector
@@ -222,33 +222,26 @@ 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 rocket frame
225+
# Angular velocity of the rocket in the body frame
226226
omega = Vector(u[10:13])
227227

228228
# Transform to sensor frame
229-
inertial_to_sensor = self._total_rotation_matrix @ Matrix.transformation(
230-
u[6:10]
231-
)
232-
W = inertial_to_sensor @ omega
229+
W = self._total_rotation_sensor_to_body @ omega
233230

234231
# Apply noise + bias and quantize
235232
W = self.apply_noise(W)
236233
W = self.apply_temperature_drift(W)
237234

238235
# Apply acceleration sensitivity
239236
if self.acceleration_sensitivity != Vector.zeros():
240-
W += self.apply_acceleration_sensitivity(
241-
omega, u_dot, relative_position, inertial_to_sensor
242-
)
237+
W += self.apply_acceleration_sensitivity(omega, u_dot, relative_position)
243238

244239
W = self.quantize(W)
245240

246241
self.measurement = tuple([*W])
247242
self._save_data((time, *W))
248243

249-
def apply_acceleration_sensitivity(
250-
self, omega, u_dot, relative_position, rotation_matrix
251-
):
244+
def apply_acceleration_sensitivity(self, omega, u_dot, relative_position):
252245
"""
253246
Apply acceleration sensitivity to the sensor measurement
254247
@@ -260,8 +253,6 @@ def apply_acceleration_sensitivity(
260253
The time derivative of the state vector
261254
relative_position : Vector
262255
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
265256
266257
Returns
267258
-------
@@ -271,7 +262,7 @@ def apply_acceleration_sensitivity(
271262
# Linear acceleration of rocket cdm in inertial frame
272263
inertial_acceleration = Vector(u_dot[3:6])
273264

274-
# Angular velocity and accel of rocket
265+
# Angular accel of rocket in body frame
275266
omega_dot = Vector(u_dot[10:13])
276267

277268
# Acceleration felt in sensor
@@ -281,7 +272,7 @@ def apply_acceleration_sensitivity(
281272
+ Vector.cross(omega, Vector.cross(omega, relative_position))
282273
)
283274
# Transform to sensor frame
284-
A = rotation_matrix @ A
275+
A = self._total_rotation_sensor_to_body @ A
285276

286277
return self.acceleration_sensitivity & A
287278

rocketpy/sensors/sensor.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,23 +460,23 @@ def __init__(
460460

461461
# rotation matrix and normal vector
462462
if any(isinstance(row, (tuple, list)) for row in orientation): # matrix
463-
self.rotation_matrix = Matrix(orientation)
463+
self.rotation_sensor_to_body = Matrix(orientation)
464464
elif len(orientation) == 3: # euler angles
465-
self.rotation_matrix = Matrix.transformation_euler_angles(
465+
self.rotation_sensor_to_body = Matrix.transformation_euler_angles(
466466
*np.deg2rad(orientation)
467467
).round(12)
468468
else:
469469
raise ValueError("Invalid orientation format")
470470
self.normal_vector = Vector(
471471
[
472-
self.rotation_matrix[0][2],
473-
self.rotation_matrix[1][2],
474-
self.rotation_matrix[2][2],
472+
self.rotation_sensor_to_body[0][2],
473+
self.rotation_sensor_to_body[1][2],
474+
self.rotation_sensor_to_body[2][2],
475475
]
476476
).unit_vector
477477

478478
# cross axis sensitivity matrix
479-
_cross_axis_matrix = 0.01 * Matrix(
479+
cross_axis_matrix = 0.01 * Matrix(
480480
[
481481
[100, self.cross_axis_sensitivity, self.cross_axis_sensitivity],
482482
[self.cross_axis_sensitivity, 100, self.cross_axis_sensitivity],
@@ -485,7 +485,9 @@ def __init__(
485485
)
486486

487487
# compute total rotation matrix given cross axis sensitivity
488-
self._total_rotation_matrix = self.rotation_matrix @ _cross_axis_matrix
488+
self._total_rotation_sensor_to_body = (
489+
self.rotation_sensor_to_body @ cross_axis_matrix
490+
)
489491

490492
def _vectorize_input(self, value, name):
491493
if isinstance(value, (int, float)):

0 commit comments

Comments
 (0)
0