================================================================================
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 :
- for the Miss Europa airplane :
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:
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:
Below are the AVL files used to generate the coefficients of the Miss Europa:
And the resulting file for Simulink:
================================================================================
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.
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.
Tags:
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.
Dear Ric,
Refer to this post for more clarifications.
http://diydrones.com/forum/topics/building-a-kalman-filtering-frame...
The C17 is a smaal foam uav, of course not the real one :D
Hi Mohamed,
I'll try to answer all of your questions.
1- No, I haven't used the EKF in real flights. I programmed the EKF just to evaluate the performance of the complementary filter (in our case the DCM). This is why I have also used the GPS for the yaw angle correction. I found out that the complementary filter is 10 times less performant than the EKF filter. But it is maybe 100 times less thirsty in terms of CPU power. I would say that the accuracy of the EKF is of 1°, the accuracy of the complementary filter is of 5 to 10°. I have also tried the UKF, but not in the attitude estimation context. Somebody in the Aerospace world told me that the UKF works well for the attitude estimation problem, something near as 0.1° of precision.
2- The wind estimation algorithm works well, but you don't really need it. In the beginning, W. Premerlani developped the wind estimation algorithm because the Course over Ground from the GPS had a time lag. So he decided to guide his UAV by controlling its heading. The UAV heading has no time lag because it is extracted from the estimated Direct Cosine Matrix. But a problem arose in case of wind... So Bill (William) imagined his wind estimation algorithm so as to correct the DCM yaw estimation and also the commanded heading in order to counteract the effect of the wind.
But recently Bill developped a simple but reliable GPS time lag correction algorithm and a simple IMU from which a nice course over ground can be extracted. Now the UAV is guided by the means of a commanded course over ground, so the wind estimation algorithm is not really needed anymore.
But yes the wind estimation algorithm works, but you need to fly a few circles in order to have a reliable estimation of the wind vector.
3- I personnaly have not used the magnetometer. Bill wrote a calibration algorithm (UAVDevBoard).
Regards,
Paul
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
I'm sure the EKF code is reliable. If you want to use the magnetometer for the yaw correction, then you don't need to retard the estimated yaw before comparing it to the measured one. I suggest you compare the XY projection of the magnetic vector with the estimated yaw.
But I can't help you with this sensor because I don't have any experience with it. Sorry.
Maybe Bill Premerlani can help you or at least knows someone that can.
Regards,
Paul
Thanks Paul for the answer.
Can you please link me to Bill Premerlani?
Thanks again.
Hi Mohamed,
You can find William Premerlani among my freinds on DIY Drones. Just send him a personal message.
Good luck,
Paul
dear sir
great work. any reference material for aerodynamic equations and stability coefficient used in this simulation.
regards
saba
1123 members
4 members
283 members
1074 members
77 members
© 2019 Created by Chris Anderson. Powered by