Skip to content

Commit

Permalink
Commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Medina committed Jan 27, 2024
1 parent ddf1006 commit 536f606
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions paseos/attitude/attitude_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,40 +36,50 @@ class AttitudeModel:
_actor_pointing_vector_body = None
_actor_pointing_vector_eci = None

# _actor_prev_pos = None
def __init__(
self,
local_actor,
# initial conditions: (defaults to 0)
actor_initial_attitude_in_rad: list[float] = [0.0, 0.0, 0.0],
actor_initial_angular_velocity: list[float] = [0.0, 0.0, 0.0],
# pointing vector in body frame: (defaults to z-axis)
actor_pointing_vector_body: list[float] = [0.0, 0.0, 1.0]
## add args with default value = ...
# actor_dipole
# actor_drag_coefficient (more for geometric model)
# body_J2
# initial conditions:
actor_initial_attitude_in_rad: list[float] = [0., 0., 0.],
actor_initial_angular_velocity: list[float] = [0., 0., 0.],
# pointing vector in body frame: (defaults to body z-axis)
actor_pointing_vector_body: list[float] = [0., 0., 1.]
):
""" Creates an attitude model to model actor attitude based on
initial conditions (initial attitude and angular velocity) and
external disturbance torques.
Args:
actor (SpacecraftActor): Actor to model.
actor_initial_attitude_in_rad (list of floats): Actor's initial attitude ([roll, pitch, yaw]) angles.
Defaults to [0., 0., 0.].
actor_initial_angular_velocity (list of floats): Actor's initial angular velocity vector.
Defaults to [0., 0., 0.].
actor_pointing_vector_body (list of floats): User defined vector in the Actor body. Defaults to [0., 0., 1]
"""
self._actor = local_actor
# convert to np.ndarray
self._actor_attitude_in_rad = np.array(actor_initial_attitude_in_rad)
self._actor_angular_velocity = np.array(actor_initial_angular_velocity)

# normalize inputted pointing vector & convert to np.ndarray
self._actor_pointing_vector_body = np.array(
actor_pointing_vector_body
) / np.linalg.norm(np.array(actor_pointing_vector_body))

# pointing vector expressed in Earth-centered inertial frame
self._actor_pointing_vector_eci = rpy_to_eci(
body_to_rpy(self._actor_pointing_vector_body, self._actor_attitude_in_rad),
np.array(self._actor.get_position(self._actor.local_time)),
np.array(self._actor.get_position_velocity(self._actor.local_time)[1]),
)

# angular velocity vector expressed in Earth-centered inertial frame
self._actor_angular_velocity_eci = rpy_to_eci(
body_to_rpy(self._actor_angular_velocity, self._actor_attitude_in_rad),
np.array(self._actor.get_position(self._actor.local_time)),
np.array(self._actor.get_position_velocity(self._actor.local_time)[1]),
)
self._first_run = True

def nadir_vector(self):
# unused but might be useful during disturbance calculations or pointing vector relative position
Expand Down

0 comments on commit 536f606

Please sign in to comment.