Skip to content
This repository has been archived by the owner on Mar 14, 2021. It is now read-only.

Linearization #37

Open
parthp08 opened this issue Jun 17, 2019 · 16 comments
Open

Linearization #37

parthp08 opened this issue Jun 17, 2019 · 16 comments

Comments

@parthp08
Copy link
Contributor

No description provided.

@parthp08
Copy link
Contributor Author

Hello,
Currently i am thinking of linearization this way
Linearization (ac, states, controls). returns A and B matrix.
Aircraft model will be a parameter but what about flat earth model.
Should just include it as default arguments to this function or you would like to use only flat earth model.

@AlexS12
Copy link
Owner

AlexS12 commented Jun 17, 2019

what if we couldalso include the system to be linearized? I agree that maybe the system making more sense is euler flat Earth, but think about quaternions flat Earth for example.

If we could choose a system it would be linked to the states and inputs. Maybe we can create some useful structs. These structs would also be useful for integration. We should also be able to choose a different system model in the simulation part.

What do you think?

I imagine something like:

linearize(ac, dynamic_system, state0, controls0)

It could return a LinearizedSystem that would contain the linearized matrix and could be passed to some methods related to integration of the linear system, control...

@parthp08
Copy link
Contributor Author

Can you elaborate on systems? And dynamic_system? I Mena what kind of inputs that it will have

@parthp08
Copy link
Contributor Author

Are you talking about matlab ss like function. That contains whole system in state space form

@AlexS12
Copy link
Owner

AlexS12 commented Jun 17, 2019

For me, the output of the linearization could be like state-space matrix given by ss. This one would take the continuous-time nonlinear model (such as Euler flat Earth) with the aircraft and linearize the whole system around state0, controls0

@AlexS12
Copy link
Owner

AlexS12 commented Jun 19, 2019

The other day I didn't have much time to elaborate this. I don't know if I answer your question clearly enough.

Thinking about it from the outside, I imagine something like this (I missed some arguments the other day)

# Initialize aircraft
ac = F16()

# Initialize controls
fcs = F16FCS()

# Initialize state
pos = PositionEarth(0.0, 0.0, 0.0)
att = Attitude(0.0, 0.0, 0.0)
vel = [100.0, 0.0, 0.0]
ang_vel = [0.0, 0.0, 0.0]
accel = [0.0, 0.0, 0.0]
ang_accel = [0.0, 0.0, 0.0]

state0 = State(pos, att, vel, ang_vel, accel, ang_accel)

# Initilize environment
atm = AtmosphereISA(pos)
wind = ConstantWind(0.0, 0.0, 0.0)
grav = EarthConstantGravity()
env = Environment(atm, wind, grav)


linear_system = linearize(ac, :six_dof_euler_fixed_mass, state0, fcs, env)
# Or maybe we need a struct for the dynamic system with some information about it
linear_system = linearize(ac, SixDofEulerFixedMass, state0, fcs, env)

# Then we could do things like
get_A(linear_system)
get_B(linear_system)

get_transition_matrix(linear_system, dt)

I will post now something about the internals of linearize if you need it

but the main thing you have to keep in mind is that the interface to calculate aircraft forces and moments, implies FCS, AeroState, State, ... and then the interface to the dynamic system uses system (vector), forces (vector), moments (vector) ....

I guess some interfaces will seem inadequate or unnatural for this purpose. Let's try to identify and improve them

@parthp08
Copy link
Contributor Author

Sorry for the late reply. It was a busy day.
I tried linearization with same function from 3dof example. But this six_dof_model have only dependent on states and forces and moments are predefined. We need new function for that that can incorporate the changes in force and moments when we apply perturbation.

There is another way we can define linearization using stability coefficient. This method is used in most books. What do you think about it? It would be easier to define it.

@AlexS12
Copy link
Owner

AlexS12 commented Jun 20, 2019

Don't worry!

I know six_dof model has forces and moments as parameters, but it is not a problem if aircraft is recalculated for each perturbation. That would be the forces and moments that need to be used as a parameter in six_dof function

It would be something like:

perturbate state or controls
update State and FCS
calculate aircraft to extract forces and moments
use forces and moments together with State and FCS in the six_dof to obtain the state_dot


There is another way we can define linearization using stability coefficient. This method is used in most books. What do you think about it? It would be easier to define it.

We could also implement other linearization options of course

@parthp08
Copy link
Contributor Author

Hi Alex,
i created linearization file https://github.com/parthp08/FlightMechanics.jl/blob/master/src/aircrafts/Linearization.jl.
please check and comment on it if any modifications is required.

@parthp08 parthp08 reopened this Jun 24, 2019
@AlexS12
Copy link
Owner

AlexS12 commented Jun 24, 2019

Hi @parthp08 I dind't have much time today to have a detailed look at it. I think it is a good starting point.

My proposal is the following:

  • Let's try to prepare a test case in the tests folder. F16 is tested against Stevens, so anything else regarding linearization should be ok if linearization is ok.
  • Once the test case is passing and reproducing Stevens will be sure that we have an example that is working properly
  • From that moment on, we can improve the code incrementally without breaking the tests: changing names, making functions more generic when needed, adapting interfaces for other cases...

Do you agree on this strategy?

Perhaps, it easier to review if you open a pull request with these changes. I noticed you have more changes in your master joining several files into one and so on as we talked at some point before. Maybe it is better to review those changes before / after in a separate PR. Is it ok for you?

@parthp08
Copy link
Contributor Author

parthp08 commented Jun 25, 2019

  • Let's try to prepare a test case in the tests folder. F16 is tested against Stevens, so anything else regarding linearization should be ok if linearization is ok.

i made a test for coordinated turn case (page 205 in stevens book) but in book data is given in states vt, alpha and beta and we have u, v, w and i dont know how to convert in matrix. can you help with it ?

Do you agree on this strategy?

yes, that is a good approach.

Perhaps, it easier to review if you open a pull request with these changes. I noticed you have more changes in your master joining several files into one and so on as we talked at some point before. Maybe it is better to review those changes before / after in a separate PR. Is it ok for you?

i didnt open pull request because linearization is not fully tested.
and regarding other changes, they didnt affect any other files and work just like before. i tested them on both local machine and travis-cl.

@parthp08
Copy link
Contributor Author

i made a test for coordinated turn case (page 205 in stevens book) but in book data is given in states vt, alpha and beta and we have u, v, w and i dont know how to convert in matrix. can you help with it ?

answer is matching for most other states such as p, q, r, theta and psi. just need some help with u, v and w.

@AlexS12
Copy link
Owner

AlexS12 commented Jun 25, 2019

There are two options:

I think the second one may be suitable.

@parthp08
Copy link
Contributor Author

can you do this? i tried but i dont think that is working.
https://github.com/parthp08/FlightMechanics.jl/blob/master/test/simulator/aircrafts/linearization.jl
https://github.com/parthp08/FlightMechanics.jl/blob/master/test/simulator/aircrafts/A_coordinated_turn.xlsx
check out this two files. problem is that u, v, and w inside A-matrix are dependent on each other and also on the other state so how to convert them.
i tried using x_dot = A * x. that also did not match.
https://github.com/parthp08/AeroBenchVVPython/blob/master/code/parth_lin.py
check this out if needed.

@AlexS12
Copy link
Owner

AlexS12 commented Jun 30, 2019

Sorry. I didn't have much time during the week. I will try to have a look next week. I didn't have a look yet, but I guess you are trying to introduce that inside A matrix. I think it's easier to use A to calculate a perturbed state and then convert from tas, alpha, beta to u, v, w. Do you have information to make a test like that?

@parthp08
Copy link
Contributor Author

parthp08 commented Jul 3, 2019

Sorry. I didn't have much time during the week. I will try to have a look next week.

that ok, i 've been busy myself.

I didn't have a look yet, but I guess you are trying to introduce that inside A matrix. I think it's easier to use A to calculate a perturbed state and then convert from tas, alpha, beta to u, v, w. Do you have information to make a test like that?

i think to do that we need to change use vt, alpha, beta for whole system.
and i dont have any other info regarding test to convert them inside A-matrix.

we can check using x_dot = A * x + B * u and then converting u_dot, v_dot, w_dot to vt_dot, alpha_dot, beta_dot. check out files i mentioned above i did that but in our case results didnt match.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants