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.

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

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

 

Views: 5599

Comment by Rhett "Wreck" Phillips on February 19, 2010 at 3:52pm
Very cool, I wish MATLAB wasn't so expensive. I'm not familiar with AVL, I'll look into it. Thank you for the post!
Comment by Borja Martos on February 19, 2010 at 7:46pm
To compile EKF.c in MATLAB using MATLAB's

mex -setup

Select a compiler:
[1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2008a\sys\lcc\bin

I had to create an EKF.h fileEKF.h
Comment by Borja Martos on February 19, 2010 at 7:54pm
Thanks for the code Paul!

Have you done any work integrating additional states into the EKF to obtain Position and Velocity in NED?
Comment by Paul Bizard on February 20, 2010 at 2:41am
Hi Borja,

Thanks, I forgot to talk about the selection of the compiler.

No I did not work on integrating additional states. But I will one day.

Today I own a UAVDevBoard with "DCM inside". It is a good product.
But I am willing to assemble/buy a more powerful board in order to play with this EKF and with one integrating Position & Velocity. I think this is the only way around because GPS is not accurate and is not "loss of signal"-proof.
The EKF I uploaded is very similar to Bill Premerlany's DCM in the sense that its structure is the same: I used a quaternion to miniminize the dimension of the state vector (4 states quaternion and 3 gyro biases = 7 states) but the correction is based on the same Roll-Pitch / Yaw decoupling and even the expression for the RP and Y deviations are the same. The RP & Yaw error vectors are essential for the accuracy and robustness of the identification process. (Bill P. has a powerful 3D/algebraic vision).

As you can see I used the GPS cog for yaw correction, exactly as DCM does, and I delayed the quaternion before correction in order to phase the two cog (GPS and estimate). This is also done in DCM, anyway in case of the EM406.

I want next to use a magnetomater rather than GPS for yaw estimation, so I will have modify the yaw correction subfunction.
Comment by Paul Bizard on February 20, 2010 at 2:53am
Thanks Rhett,

The interesting point is that AVL is relatively accurate and with this simulator you can tune your gains, at least for the first flight.

The process of computing the airplane coefficients with AVL is not straightforward for a newbie, but is worth the pain.

Developer
Comment by Pete Hollands on February 20, 2010 at 3:29am
Here is the link for Mark Drela's AVL program for those that are new to this software.

Developer
Comment by Pete Hollands on February 20, 2010 at 3:35am
Paul,

you wrote: But I am willing to assemble/buy a more powerful board in order to play with this EKF and with one integrating Position & Velocity.

Currently the UAV Devboard is using 6% of it's CPU power for the latest version of MatrixPilot at the head of the trunk of development. So there is a lot of spare CPU power to integrate position and velocity. I know that Bill is starting to think now about returning to a "Dead Reckoning" model for position, with the GPS re-calibrating the "Dead Reckoning". This will mean that we know our position every 1/40th of a second.

So I believe we will be undertaking more integration of velocity in MatrixPilot on the UAV Devboard quite soon.

Pete
Comment by Paul Bizard on February 20, 2010 at 4:25am
Hi Pete,

Yes, I've read about this on UDB Google Group, but I want to follow the EKF path and I beleive in the simple airspeed measurement rather than its estimation. The airspeed sensor is not that expensive and I favor simple solutions.
I also think that a magnetometer is required for a rock solid yaw estimation. (What will happen if a gust of wind reverses the speed for 20 seconds ? The estimated yaw will have 180° of error ?). I am concerned about a catastrophic series of events.
Nonetheless, what has been -and is being- achieved by Bill and all of you with such a simple cheap board is incredible. I am also happy to have helped Bill a little. I will fly FPV this summer with the UDB.

Your latest developments are outstanding and together you make up a great team.

Developer
Comment by Pete Hollands on February 20, 2010 at 5:13am
"I am also happy to have helped Bill a little." Thank you for your contributions. They were an absolutely vital part of the early success of DCM and the UAV DevBoard.

Developer
Comment by Mark Colwell on February 20, 2010 at 6:28am
Bill, Paul, & Pete,
Thank You, for all the fine documentation and clear discussions on DCM, I have learned a boat load, and stand on your coat tails. I am working on ArduPilot IMUv1 , and very near to good high speed flight with neutral stable Stryker II I hope to win SF competition this year.

Comment

You need to be a member of DIY Drones to add comments!

Join DIY Drones

Contests

Season Two of the Trust Time Trial (T3) Contest has now begun. The third round was a reliablilty/aerial photography round for both planes and copters, which is now closed. Stay tuned for the next round, beginning soon.

A list of all T3 contests is here

 

© 2012   Created by Chris Anderson.

Badges  |  Report an Issue  |  Terms of Service