Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attitude model #194

Merged
merged 58 commits into from
Jan 19, 2024
Merged

Conversation

Mr-Medina
Copy link
Collaborator

Description

An attitude model is added, simulating the evolution of a spacecraft actor attitude through time with external attitude disturbances. User can specify initial contitions: spacecraft attitude (being roll, pitch and yaw angles) and angular velocity.
Disturbance torque calulations are not implemented yet but framework is present for later implementation.

Reference frame transfer file is also made in utils, able to switch between Earth-centered inertial, roll pitch yaw (based on nadir & along track directions) and body fixed frames. Also used for vector rotations in reference frames and extracting roll, pitch, and yaw angles between frames.
Summary of changes

  • attitude model added
  • reference frame transformation functions added
  • disturbance calculations framework added

Resolved Issues

How Has This Been Tested?

I made a file which plots the pointing vector in the spacecraft trajectory using matplotlib. I was not sure if I needed to add this in the PR. Please refer to my fork to file "test_attitude_plotting.py" for visual reference.
Further testing methods will be added after feedback is received.

…of floats, outputs: numpy arrays (needs to be reviewed in implementation)
…l and magnetic) on actor. started with set_attitude_model and attitude model class as well.
deleted redundant function (which I added myself)
pointing vector function
…) doesn't produce correct pointing vectors, need to find solution to transform vector from body to ECI with non-zero 3d attitude angle vector (roll, pitch, yaw), resulting in correct pointing.
…nting vectors. Exact workings of these rotations not understood fully yet, needs more looking into. next step: add accelerations
…are correct. Find relationship between theta1 and thata2 and roll - pitch - yaw
… with rodriguez' rotations and get attitude with new function
…relative to previous timestep (instead of t0, this avoids problems for later) and rpy angles are now correctly implemented (with default order y-p-r)
Final commits before pull request
@gomezzz
Copy link
Collaborator

gomezzz commented Jan 11, 2024

@Mr-Medina Should we have a look and give you some feedback? :)

You can request a review in the top right with

grafik

Copy link
Collaborator

@GabrieleMeoni GabrieleMeoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a first glance, it looks good. We can have a dedicated discussion later on. I would wait for the geometric model PR to be updated as requested. This code needs also to capitalize on that PR.

np.array([Tx, Ty, Tz]): total combined torques in Nm
"""

T = np.array([0.0, 0.0, 0.0])
Copy link
Collaborator

@GabrieleMeoni GabrieleMeoni Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent with what you are doing later, T shall be expressed with respect to the body frame. Can you confirm?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the T vector will be expressed in the body frame

def calculate_angular_acceleration(self):
"""Calculate the spacecraft angular acceleration (external disturbance torques and gyroscopic accelerations)"""
# todo: implement geometric model
# I = self._actor_moment_of_inertia
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need a placeholder? Why don't you capitalize on your previous PR? Also, from the comment on the previous PR, can you confirm that I is expressed with respect to the body frame?

I = np.array([[50, 0, 0], [0, 50, 0], [0, 0, 50]]) # test placeholder

# Euler's equation for rigid body rotation: a = I^(-1) (T - w x (Iw))
# a = angular acceleration, I = inertia matrix, T = torque vector, w = angular velocity
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Torque is only due to disturbances for the moment. I would add a comment including TODO for future implementations considering additional control torques due to actuators.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

p = body_to_rpy(self._actor_pointing_vector_body, self._actor_attitude_in_rad)
return x, y, z, p

def update_attitude(self, dt):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure this function is always called inside PASEOS main loop to be sure the variables will be updated all at the same time:

while self._state.time < target_time:

@Mr-Medina Mr-Medina changed the base branch from main to attitude-model January 19, 2024 14:39
@Moanalengkeek Moanalengkeek merged commit ff93e5f into aidotse:attitude-model Jan 19, 2024
0 of 3 checks passed
@Mr-Medina Mr-Medina mentioned this pull request Jan 19, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attitude model
4 participants