In case anyone here is using Matlab and Simulink to test or develop UAVs and UAV autopilots I am posting a link to a new flight dynamic model SFunction for use with Simulink- http://jsbsim.sf.net/JSBSimSFunction.zip

 

The project enables any JSBSim flight dynamic model to be run within Simulink.  It also has a trim utility as well as a linearization utility that prints formatted, de-coupled state space matrices to the command window.  This makes it extremely useful for flight control or autopilot design. An eigenvalue analysis is also performed after the linearization.

 

The project is open-source and all the source code is included with the project download.  It has been tested with Matlab R2008b and R2010a.  Currently there is an issue with R2010a that causes the resulting trimmed control inputs to be slightly off- hopefully we can get this fixed soon.  Pre-compiled MEX files exist for win64/32 currently, with Mac OS and hopefully Linux versions in hte near future.

 

Happy downloading!

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

Join diydrones

Email me when people reply –

Replies

  • Does it have any problem with Matlab 2012 a ? 

  • Hello everyone,

    I am new to Matlab SFunction. I have downloaded JSBSimSFunction and the aircraft models. I have also installed Visual Studio C++ 2008 Express Edition. I can start up the GUI and load a model. However, I cannot initialize the model and Matlab gives me the following error

    Error using JSBSimGUI>init_model_Callback (line 1850)
    Error while obtaining sizes from MEX S-function 'JSBSim_SFunction' in
    'jsbsimgui_test/JSBSim S-Function'.

    Error in gui_mainfcn (line 96)
            feval(varargin{:});

    Error in JSBSimGUI (line 42)
        gui_mainfcn(gui_State, varargin{:});

    Error in
    @(hObject,eventdata)JSBSimGUI('init_model_Callback',hObject,eventdata,guidata(hObject))


    Caused by:
        Error using JSBSimGUI>init_model_Callback (line 1850)
        Invalid MEX-file
        'C:\Users\Don\Documents\MATLAB\JSBSimSFunction\JSBSim_SFunction.mexw32':
        C:\Users\Don\Documents\MATLAB\JSBSimSFunction\JSBSim_SFunction.mexw32 is not a
        valid Win32 application.
     
    Error while evaluating uicontrol Callback

    I guess I did not correctly compile the mexw32 file. Can you please give me some instruction to do that?

    Thanks,

    Donald

  • Hi. Excellent work! Thank you for sharing this.

    I have Matlab 7.1 (R14) and Visual Studio Express Edition 2010. Will I be able to use your files with the tools I currently have? My machine is running Win XP, but I plan on moving to my Win7 (32 bit) machine soon.
  • Hi Nikki,

    OK, I found an error in the simulink model used for the trim- not sure how that version made it into the release but it only trims the 'f16' model, no matter what model you select. This would explain why the C172 model will not trim. I will be updating the project release very soon and will definitely fix this.

    Check this thread soon and I will have a link to a new download with some of the most pressing changes....
  • Hi Niki,

    Thanks for giving the project a try! To address your problem with the trim, let me first tell you what someone more knowledgeable of the subject than I has said on more than one occasion- "trimming an aircraft is a non-trivial task." What he means is that even with the help of programs like Matlab, trimming a non-linear flight model for a specific aircraft is not supposed to be easy- though it is our goal to eventually make it easy :). The Matlab default trim function used by the trim routine requires initial controlo inputs and states that are very close to a trimmed condition for the particular aircraft you are trying to trim. So basically, in order to get a good trim output, you almost need to know what the trimmed control inputs are in order to initialize it....frustrating I know. In all fairness, the current state of the trim routine is pretty beta and it is expected that the user will need to tinker with some of the m-code settings. This "tuning" process was to be outlined in a white paper that I am working on...off and on ;). However, more recently it has been decided to really try to overhaul the trim function (and the GUI for that matter) and attempt to make it much easier to trim any given aircraft model without needing to spend hours (or days) trying different control settings, pre-trim gain settings etc.

    Please be patient and tinker with the SFunction in its current state because the changes that are planned are pretty exciting!

    Cheers
    Brian Mills
  • Hy Brian,

    great job!what you are creating is very intersting and useful.
    Unfortunatly i tried your JSBSimSFunction on different plane and i am not very sure that it works. Probably i do some mistakes but the button perform initial trim doesn't seem to be good. I mean it gives uncorrect result if I change the plane (cessna172x,p,r) instead of use f16. Besides if I use f16 perform initial trim gives a result but if I try to do the simulation in simulink (60 seconds) the plane crashes.
  • thanks for ur information.May I know ur AeroSim experinces and the permission of U-Dynamics of course more.
    Thanks.
  • great Mills!
    Thanks for ur happy downloading. I wanna to suggest for coupling control(lateral and longitudinal control) and do u use AeroSim software.

    May I know how to consider the inertia effect for airplane.Please let's me know about that.

    Thanks
This reply was deleted.

Activity

Neville Rodrigues liked Neville Rodrigues's profile
Jun 30
Santiago Perez liked Santiago Perez's profile
Jun 21
More…