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

DIY Robocars via Twitter
RT @Smartphone89: DonkeyCar Racing League Korea #donkeycar @diyrobocars https://t.co/mDlHDR1d98
yesterday
Jørn Ramnæs liked VIDEO LINK's profile
Friday
Mark Harrison left a comment on Moderators
"Wow, Ning2 looks really great on mobile. I had sort of drifted away as my browse-time went more on my phone, so this is great."
Friday
Hank Deucker left a comment on PIXHAWK
"I am sure most will say not again, Pixhawk telemetry. I do need help and all can be reassured that I have spent many hours scouring the net for useful information. I am not new at quadcopter flying, I started in 2012 and have progressed through many…"
Thursday
DIY Robocars via Twitter
https://t.co/rLmFr8M2UK
Thursday
Hank Deucker left a comment on PIXHAWK
"Tomorrow, I am thinking about the wording at the moment."
Thursday
DIY Drones via Twitter
Welcome to the new DIY Drones design!. You may have noticed that DIY Drones looks a little different today. That's… https://t.co/cg2EmeDGMQ
Wednesday
DIY Drones via Twitter
New! Online Training on Drones for Disaster Response https://t.co/brqRuujjY2
Tuesday
DIY Robocars via Twitter
https://t.co/8EMCvYW6oz
Tuesday
DIY Robocars via Twitter
RT @OttawaAVGroup: We are going to try something new this week. We will be having a drop-in style meeting Wednesday @ 7-9pm EST. Pop in and…
May 25
DIY Robocars via Twitter
RT @tawnkramer: Thanks Everyone for another fun virtual race! Amazing Ai racers competing head-to-head, Virtual Makers Fair event. Catch us…
May 23
DIY Robocars via Twitter
RT @make: Find out the latest from @diyrobocars at 10am PT from @chr1sa of @3DRobotics on Virtually Make Faire! #makerfaire #maketogether #…
May 23
DIY Robocars via Twitter
RT @Heavy02011: Join us Saturday online: Virtual Race League: @DIYRobocars Race #2 - Parking Lot Nerds https://t.co/aJUu4sdutx #Meetup via…
May 22
DIY Robocars via Twitter
RT @donkey_car: Yay, we are part of the virtual @makerfaire with @diyrobocars. Come see our race or better yet train a model and race with…
May 21
DIY Robocars via Twitter
RT @chr1sa: The @DIYRobocars Virtual AI Race is going to be part of the virtual @makerfaire on Sat! https://t.co/wnMDAboLID
May 20
DIY Robocars via Twitter
RT @tawnkramer: Please join us next week for our second DIYRobocars online race. We will be using a new Mountain Track course! https://t.co…
May 19
More…