Added observers for tracking data

This commit is contained in:
dario
2023-12-13 11:18:23 +01:00
parent 22d6280123
commit b331e9b27a
7 changed files with 240 additions and 167 deletions

View File

@@ -131,7 +131,7 @@ class Dataset(Advanceable):
ArrayLike: The current transformation matrix from local to body-fixed coords.
"""
# Get the rotation in the local coordinate system.
rots = self.__fetch_values(['pitch_l', 'yaw_l', 'roll_l'])
rots = self.fetch_values(['pitch_l', 'yaw_l', 'roll_l'])
pitch_l, yaw_l, roll_l = rots[0], rots[1], rots[2]
return self.T1(roll_l) @ self.T2(pitch_l - math.pi/2) @ self.T1(-yaw_l)
@@ -141,8 +141,8 @@ class Dataset(Advanceable):
Returns:
ArrayLike: The current transformation matrix from global to local coords.
"""
decl = self.__fetch_value('declination')
long = self.__fetch_value('longitude')
decl = self.fetch_value('declination')
long = self.fetch_value('longitude')
t0 = self.__df['time'].iloc[0]
omega_E = (2*math.pi) / (24*60*60)
@@ -189,7 +189,7 @@ class Dataset(Advanceable):
"""
return self.get_mach_number() > 1
def __fetch_value(self, name: str) -> float:
def fetch_value(self, name: str) -> float:
"""Get a specific value from the dataframe.
Args:
@@ -212,7 +212,7 @@ class Dataset(Advanceable):
# Interpolate linearly between the two data points.
return (1 - alpha) * self.__df[name].iloc[self.__idx] + alpha * self.__df[name].iloc[self.__idx + 1]
def __fetch_values(self, names: List[str]) -> np.array:
def fetch_values(self, names: List[str]) -> np.array:
"""Get specific values from the dataframe.
Args:
@@ -221,14 +221,14 @@ class Dataset(Advanceable):
Returns:
np.array: Returns a numpy array containing the requested values in the same order as in the input list.
"""
return np.asarray([self.__fetch_value(name) for name in names])
return np.asarray([self.fetch_value(name) for name in names])
def get_velocity(self) -> float:
"""
Returns:
np.array: Returns the velocity at the current time of the simulation.
"""
return self.__fetch_value('velocity')
return self.fetch_value('velocity')
def get_acceleration(self, frame='FL') -> ArrayLike:
"""_summary_
@@ -239,7 +239,7 @@ class Dataset(Advanceable):
Returns:
ArrayLike: _description_
"""
acc = self.__fetch_values(['ax', 'ay', 'az'])
acc = self.fetch_values(['ax', 'ay', 'az'])
if frame == 'B':
return self.launch_rail_to_body() @ acc
@@ -251,7 +251,7 @@ class Dataset(Advanceable):
Returns:
ArrayLike: Gets the derivatives in angular velocity across all axes of the rocket.
"""
return self.__fetch_values(['omega_X', 'omega_Y', 'omega_Z'])
return self.fetch_values(['omega_X', 'omega_Y', 'omega_Z'])
def get_velocity(self, frame='FL') -> ArrayLike:
"""
@@ -262,7 +262,7 @@ class Dataset(Advanceable):
ArrayLike: _description_
"""
vel = self.__fetch_values(['vx', 'vy', 'vz'])
vel = self.fetch_values(['vx', 'vy', 'vz'])
if frame == 'B':
return self.launch_rail_to_body() @ vel
@@ -274,63 +274,63 @@ class Dataset(Advanceable):
Returns:
float: Returns the mach number at the current time of the simulation.
"""
return self.__fetch_value('mach')
return self.fetch_value('mach')
def get_speed_of_sound(self) -> float:
"""
Returns:
float: Returns the speed of sound at the current time of the simulation.
"""
return self.__fetch_value('speedofsound')
return self.fetch_value('speedofsound')
def get_rotation_rates(self) -> np.array:
"""
Returns:
np.array: Returns the rotation rates at the current time of the simulation.
"""
return self.__fetch_values(['OMEGA_X', 'OMEGA_Y', 'OMEGA_Z'])
return self.fetch_values(['OMEGA_X', 'OMEGA_Y', 'OMEGA_Z'])
def get_rotation(self) -> np.array:
"""
Returns:
np.array: _description_
"""
return self.__fetch_values(['pitch_l', 'yaw_l', 'roll_l'])
return self.fetch_values(['pitch_l', 'yaw_l', 'roll_l'])
def get_temperature(self) -> float:
"""
Returns:
np.array: Returns the temperature at the current time of the simulation.
"""
return self.__fetch_value('temperature')
return self.fetch_value('temperature')
def get_pressure(self) -> float:
"""
Returns:
np.array: Returns the pressure at the current time of the simulation.
"""
return self.__fetch_value('pressure')
return self.fetch_value('pressure')
def get_thrust(self) -> float:
"""
Returns:
float: Returns the thrust value for the current time of the simulation.
"""
return self.__fetch_value('thrust')
return self.fetch_value('thrust')
def get_drag(self) -> float:
"""
Returns:
float: Returns the drag value for the current time of the simulation.
"""
return self.__fetch_value('drag')
return self.fetch_value('drag')
def get_mass(self) -> float:
"""
Returns:
float: Returns the mass value for the current time of the simulation.
"""
return self.__fetch_value('mass')
return self.fetch_value('mass')
if __name__ == '__main__':