Skip to content

Commit

Permalink
Updates gravity model implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Moanalengkeek committed Jan 25, 2024
1 parent c792502 commit acb6aee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions paseos/attitude/attitude_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def calculate_disturbance_torque(self, position, velocity, euler_angles):
T += calculate_aero_torque()
if "gravitational" in self._actor.get_disturbances():
T += calculate_grav_torque(self._actor_pointing_vector_body,earth_rotation_vector_in_body,
self._actor._moment_of_inertia, self._actor._previous_altitude)
self._actor._moment_of_inertia, position[0])
if "magnetic" in self._actor.get_disturbances():
T += calculate_magnetic_torque()
return T
Expand All @@ -118,7 +118,9 @@ def calculate_angular_acceleration(self):
# Euler's equation for rigid body rotation: a = I^(-1) (T - w x (Iw))
# with: a = angular acceleration, I = inertia matrix, T = torque vector, w = angular velocity
self._actor_angular_acceleration = np.linalg.inv(I) @ (
self.calculate_disturbance_torque()
self.calculate_disturbance_torque(position=np.array(self._actor.get_position(self._actor.local_time)),
velocity=np.array(self._actor.get_position_velocity(self._actor.local_time)[1]),
euler_angles=self._actor_attitude_in_rad)
- np.cross(self._actor_angular_velocity, I @ self._actor_angular_velocity)
)

Expand Down
3 changes: 2 additions & 1 deletion paseos/attitude/disturbance_calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def calculate_grav_torque(u_r, u_n, J, h):
tg_term_2 = 30 * np.dot(u_r, u_n) * (np.cross(u_n, J * u_r) + np.cross(u_r, J * u_n))
tg_term_3 = np.cross((15 - 105 * np.dot(u_r, u_n) ** 2 * u_r), J * u_r) + np.cross(6 * u_n, J * u_r)
tg = tg_term_1 + mu * J2 * Re ** 2 / (2 * r ** 5) * (tg_term_2 + tg_term_3)
return np.array(tg)
T = [tg[0,0], tg[1,1], tg[2,2]]
return np.array(T)


def calculate_magnetic_torque():
Expand Down

0 comments on commit acb6aee

Please sign in to comment.