Matlab/Simulink Simulator

================================================================================

March 8 2013 update

================================================================================

A good servo model has been added

================================================================================

Here is a Simulink simulator for the UavDevBoard MatrixPilot.

MatrixPilot has been entirely programmed (wind estimation, IMU, control loops...).

The airplane is the Scorpio Miss. This airplane is rudder only. So you will need to modify the bank control

algorithm if you want to use a plane fitted with ailerons.

The autopilot is true to the original except for the type of the variables : real rather than fractional.

Model file : Miss_Sim_MatrixPilot.mdl

Airplane file : Miss_Data.m

MatrixPilot parameter file : MatrixPilot_Parameters.m

S-Function file (IMU, DCM, wind estimation) : R.c

1- Put all the files into one directory. Run Matlab/Simulink, go to the directory.

2- Compile the S-Function   (instruction : mex R.c at the Matlab prompt)

3- Load the parameters       (instruction : Miss_Data at the Matlab prompt)

4- Load the simulink model  (instruction : Miss_Sim_MatrixPilot at the Matlab prompt

Note:

a/ Miss_data.m will call MatrixPilot_Parameters.m

b/ Don't forget to install lcc, the Matlab default compiler. Just type and enter mex -setup at the Matlab prompt and follow the instructions

================================================================================

December 12 2012 update

================================================================================

Here is the simulator with the UavDevBoard MatrixPilot.

MatrixPilot has been entirely programmed (wind estimation, IMU, control loops...).

The airplane is the Scorpio Miss. This airplane is rudder only. So you will need to modify the bank control

algorithm if you want to use a plane fitted with ailerons.

The autopilot is true to the original except for the type of the variables : real rather than fractional.

Model file : Miss_Sim_MatrixPilot.mdl

Airplane file : Miss_Data.m

MatrixPilot parameter file : MatrixPilot_Parameters.m

S-Function file (IMU, DCM, wind estimation) : R.c

1- Put all the files into one directory. Run Matlab/Simulink, go to the directory.

2- Compile the S-Function   (instruction : mex R.c at the Matlab prompt)

3- Load the parameters       (instruction : Miss_Data at the Matlab prompt)

4- Load the simulink model  (instruction : Miss_Sim_MatrixPilot at the Matlab prompt)

================================================================================

December 20 2011 update

================================================================================

I have corrected :

- a mistake in the computation of the force wrench (bref was used instead of cref for the moment M)

subsystem Aerodynamic Model

- a mistake in the moment of inertia tensor (sign of one of the product inertia)

subsystem Equations of Motion

I have also unified the format of the stability derivatives

subsystem Aerodynamic Model and files P.m

So here are the new simulink model and the stability derivative file

- for the Super Chipmunk airplane :

Chip_Sim.mdl  Chip_Data.m

- for the Miss Europa airplane :

Miss_Sim.mdl  Miss_Data.m

These files replace the previous P.mdl and P.m files.

Here is also the DCM program you need to compile with the Matlab compiler (you may get rid of this

function if you like) R.c

================================================================================

First post 2010

================================================================================

Here is a Simulink airplane simulator working together with aerodynamic coefficients and stability

coefficients computed with Mark Drela's AVL program. The simulink model file is P.mdl:

P_sim.mdl

The aerodynamic coefficients and stability derivatives are functions of the Angle of Attack and are written

in the P.m file (Super Chipmunk): P.m

I have computed the coefficients of the CG Super Chipmunk and of the Scorpio Miss Europa. Miss Europa

is the sistership of the Super Miss, Icebear's famous airplane (good job Icebear !)

Below are the AVL files used to generate the coefficients of the Super Chipmunk:

chipmunk.avl

chipmunk.mass

FuseChipmunk.dat

naca0012.dat

Below are the AVL files used to generate the coefficients of the Miss Europa:

Miss.avl

Miss.mass

FuseMiss.dat

Clarky.dat

And the resulting file for Simulink:

P.m

================================================================================

If you want to compute the coefficients for another airplane, you need to create the .avl, .mass,

fuselage.dat and airfoil.dat files and run the AVL program a few times (for every AoA). If some of you guys

are interested, I can write a draft on the way to generate the coefficients with AVL.

If you just want to test the simulator with the Super Chipmunk, you just have to type P at the Matlab

prompt and then launch the P.mdl file.

This P.mdl simulink model has been used to test the DCM algorithm and also the EKF.

If you want to have a look, here are the R.c (DCM) and EKF.c (Extended Kalman Filter) S-Functions.

R.c

EKF.c

You need to compile them. At the Matlab prompt type "mex R.c" and "mex EKF.c"

Otherwise get rid of them in the P.mdl model.

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Hello Paul,

    Did you ever manage to write a draft on how to generate coefficients with AVL?

    thanks

    GreatPilot

  • Hello Paul,

    What I really meant was, how did you choose the natural frequencies and damping ratios of your improved servo model ?

    Thanks for your reply.

    GreatPilot

  • Hi Great Pilot, any servo is OK. If your plane is very reactive then the fastest the servo the better. The time response of a servo can limit the overall time response of the autopilot.

    Regards,

    Paul

  • Hello Paul,

    Thanks for the great work you have done.

    My question is : Do you have a reference for the servo model you chose . I think that the natural frequency of 150 Hz is too high.

    Best Regards,

    GeatPilot

  • Thanks for sharing This is great effort but i have a problem of using EKF.C instead of R.C

    I think the simulated GNC must be changed as input and output of both are different so i need help for running with the estimator EKF.C

  • Hi Saba,

    Flight stability and automatic control
    From Robert NELSON.

    Regards,
    Paul
  • dear sir

    great work. any reference material for aerodynamic equations and stability coefficient used in this simulation. 

    regards

    saba

  • Thanks Paul for the answers.

    Ok, so I will take the risk and test the EKF in real flights. 

    I will also add some safe conditions on the output of the EKF compared to the output of the DCM (which worked fine), and if it deviates a lot, then, I will switch to the DCM. Finally I will log that in real-time for after-flight analysis.

    I will also try to include the magnetometer some how for heading estimation and evaluate it's performance against the GPS.

    The reason that I am afraid of magnetometer is that it can give a total incorrect heading estimation due large disturbances, and this is why the GPS is more friendly to us. But the argument about the magnetometer is that it can provide faster and accurate heading estimation than the GPS, if it's well calibrated. The last time we flied using the magnetometer (using DCM) and we had the worst crash!

    But, still I 'd like to investigate the magnetometer in more details. I have logged all the required data during my flights for further analysis, I just need some experts to help to investigate the problem. 

    Can you help me on this, or if you know some body who can, that would be great.

    Thanks.

    M. zahana

  • Dear Paul,

    This is really a great effort, and thanks for sharing. My colleagues and I are doing some advanced controls on UAVs. Currently we are using C-17 Globemaster. We managed to have full autonomous flight with small issues during the landing, using Ardupilot Mega 2.0. I have been learning how to apply attitude estimates filters to get the best estimates for further accurate controls and navigation. We decided to use Extended Kalman fileter, and eventually ended up using your EKF code. My colleague is working on the model Identification and AoA&Side Slip angles estimation. We will be running our heavy codes on an external embedded computer (gumstix overo) and send the outputs back to the APM.

    So, I have couple of question:

    1- Have you used the EKF in real flights?

    2- did you try the wind estimation algorithm in real flights? and did work successfully?

    3- Have you used the magnetometer in heading estimation, instead of GPS? and did it work ?

    I am really interested in your fruitful experience and looking forward to cooperate with you.

    Thanks.

    M. Zahana.

This reply was deleted.

Activity