How To Connect MATLAB and Simulink to FlightGear - Full Tutorial for Beginners
HTML-код
- Опубликовано: 11 сен 2024
- #FlightGearSimulations #MathWorks #Simulink
Dear Engineers,
In this video, I go over thoroughly, the process to install FlightGear and to connect MATLAB to it. FlightGear is an open source flight simulator which is used for the simulation of aircraft dynamics. It is a very powerful tool used in the aerospace industry worldwide.
In this tutorial, I cover:
1) Setting up FlightGear
2) Installing new aircraft
3) Connecting MATLAB to FlightGear (in full step by step detail)
I would sincerely like to thank a PhD graduate from Georgia Institute of Technology, in helping me extensively with this process: His contact information is:
Imon Chakraborty, Ph.D.,
Professor, Auburn Univeristy, AL
LINKS USED IN THE VIDEO:
FlightGear: www.flightgear....
MATLAB Compatibility: www.mathworks....
New Aircraft: mirrors.ibiblio...
Code Tutorial: www-mdp.eng.cam...
MY CODE:
________________________________________________________________
SET FG_ROOT=C:\Program Files\FlightGear\data
SET FG_SCENERY=C:\Program Files\FlightGear\data\Scenery;C:\Program Files\FlightGear\scenery;C:\Program Files\FlightGear\terrasync
.\\bin\win64\fgfs --aircraft=HL21 --fdm=null --enable-auto-coordination --native-fdm=socket,in,30,localhost,5502,udp --fog-disable --enable-clouds3d --start-date-lat=2004:06:01:09:00:00 --enable-sound --visibility=15000 --in-air --prop:/engines/engine0/running=true --disable-freeze --airport=KMIA --runway=06 --altitude=8000 --heading=0 --offset-distance=0 --offset-azimuth=0 --enable-rembrandt
__________________________________________________________
~~My Udemy Courses on Motion Planning / Navigation / Trajectory Planning:
www.udemy.com/...
My Instagram: / vinayak_desh
My Website: www.vinayakd.com/
Here is Part 2!, It answers all your FAQ :)
ruclips.net/video/b-hK5-4D5Rc/видео.html
Part 3 covers way more cool stuff!
ruclips.net/video/kFklbdU9eSQ/видео.html&
You have used a joystick in this video
You are the reason I'm not just completing my bachelor's, but earning it.
Your videos are nice and best for beginner to intermediate learners. #Thanks for the upload.
Thank you for sharing, Vin! I'm a new engineer and this video will help me do my job!
Very Nice Information! I was looking for these kind of stuff especially interface of MATLAB with FlightGear!
Nice video!.
I wanted to know how does flight gear read data when user wants to send to it using generic protocol and UDP sockets
Can you help me? I cannot find aircraft model HL21 for FlightGear simulation. Where can I download it? Or can you share it with me?
When I run the bat-file it starts FG, but the window of work with the simulink model becomes unavailable, I can not start the simulation. What could it be? I'm using Matlab 2017b and FG 3.4.0. Thank you!
same problem, could you find any solution?
I had to close out of matlab, then run the batch file, then restart matlab and open Simulink. Then it allowed me to run the Simulink.
Hi all, I'm having trouble trying to get FlightGear to use the simulated data I generated in Matlab. My sh file runs, but FlightGear says "simulation paused". Any advice?
@VDEngineering Many people are getting this problem. Please give a solution.
Tanks of information you have shared 🙏😊🌹
Hi, this is a very informative video, thank you for sharing the link to the second part too. I am a student and I don't have the Simulink license so I wanted to know if I can directly use the FlightGear simulator only with MATLAB. My other query is, I want to simulate rocket trajectory so I wanted to know to what altitude does the FlightGear supports the simulation?
Thank you for the video
could we animate two moving objects in one animation?
Hi VD, I just want to know how did you create batch file and what was the code inside that batch file
@VDEnginnering, how to add airports ? Whenever I download scenery, there is no airport folder in that.
very good job, thank you !!!!!
how to get a rocket model for flightgear? And in which folder should I put the file?
wonderful
Hello, many thanks for this brilliant tutorial; is there any possibility to get the full detail of the diagram presented at 6'37 (either in slx file or by opening (in video) all elements?
Could you explain how you went about installing the HL-20 Model into FlightGear?
hey i really love your videos !!! i am trying to learn autopilot systems can you suggest any books which will help me?
Sir, I am using Matlab 2016b. HereI can not find the 'Function block parameters:h '. What should I do?
Hello! I can't to build scheme. I don't understand, where to find blocks "x", "h", "pitch". Could you explain hpw to build scheme and which characteristic did you chose in blocks?
Hello, Have you found the solution?
hey! which blocks r used for x/pitch, that '0'/ '-30 and and 'in metres'? did you find the answer?
Hi, regarding the .bat file code, what if I wish to keep the flight dynamics in flight gear? Do I simply remove '-fdm=null' or do I write something else instead? Similarly, if I wanted the aircraft to start on the ground, how do I change '--in-air'?
Try to adjust altitude to make it start on the ground, or simply change it to -ground. Let me know what works, haven't tried this myself unfortunately.
You remove fdm-null, worked for me
Although if you are running Simulink I strongly encourage you to disable the fdm
hello! thank you for video! but i have a question! ^^ Can I simulate the helicopter in that household?
Is there any way we can contact you personally?
BTW, thanx for the videos, really helpful
hey! which blocks r used for x/pitch, that '0'/ '-30 and and 'in metres'?
Can I get the full simulink design of the current circuit from anywhere???
Plzz someone tell about that..
Bro can we use flight gear for a simulink aircraft model without a physical joystick? If yes can u plz guide me on that a bit Thanks
yes
Thanks,so great videos.But I want to ask you for help about the scenery in the FlightGear.The version I used :matlab2017b,FlightGear2017.1.When I set up my FlightGear with the airport KSFO,the interface of the Fligtgear is full of sea water and sky without terrain. But in the default condition at the ENBR airport ,it is normal and right. When I run the matlab and flightgear together,the plane can fly with the only terrain problem as I said.Do you know what is wrong with my flightgear?
by the way ,the version 2017.3 flightgear is normal but matlab does not support.
You haven't installed the scenery, it has to be downloaded and installed separately from another website.
Thank you,I have solved my problem just as you said.I selected the automatic download scenery.
how can i do for Quadcopter? reply asap
Iam making a simulation of NASA space shuttle using Matlab Simulink with Flightgear Simulator.
Iam Using Matlab R2016b and Flightgear 2016.1.1 and the first time i simulate it i got undefined variable for pitch, DR but i know that first i must run the shuttle model m file then i have to run the run first m file this will make pitch, DR have values from the excel so i solved this problem but after that i have the problem in the fifth picture.
Iam a chemical engineering student in a bachelor project so i dont know so much about simulink and aerodynamics.
I want a quick reply to solve this error and thanks.
my ERROR is:
The 'Vector of input values' in block 'model/h' must be a real vector that contains at least two elements
Component:Simulink | Category:Modelerror
The 'Vector of input values' in block 'model/pitch' must be a real vector that contains at least two elements
Component:Simulink | Category:Modelerror
The 'Vector of input values' in block 'model/x' must be a real vector that contains at least two elements
Hello, i am trying to develop a rocket with a TVC control sistem for my final degree tessis and i am considering the "aerospace pack" with FlightGear simulation and the "siscape mechanics" pack, which also allow me to simulate. And I would like to ask if it is possible to upload my model to FlightGear as I can with simscape Mechanics. Thanks for all your videos, they sure help me a lot!
For anyone struggling, Christopher Lum has a more recent approach to linking Simulink and Flight Gear which is much easier and has actually worked for me. Leave the link here: ruclips.net/video/f8tdTiuj5lo/видео.html
Don't mean to undermine this tutorial. VDEngineering is such a great and helpful channel, but this particular tutorial is much more up-to-date there.
sir,
we are facing problem in connecting the maatlab simulink with flight gear .if possible please suggest the correct combination of matlab version and flight gearversion
Which version of MATLAB do you have? Please be specific, e.g. 2016a,2016b e
1)As soon as you open MATLAB, it mentions the version on the top left corner of the flash screen
2)Or, open MATLAB type in 'version'.
Report back to me
Please use the link I discuss.
You may use FlightGear 3.0, the one I use, should be fine
Thanks, just one question. Where in Simulink Library can I find the lookup that you use?
You won't find it there, use the example
@@VDEngineering which example?
sir,
can we use our simulink model with already existing flight model in flight gear .
Copy my code in the runfg.bat file, please watch the whole video,
where it says aircraft = hl21, change that to 'aircraft=c172p'
sir can u make the same video another time with detail because after some trobleshoot has happen.please do for all of us those who commemted below.it will be useful for so many members
I'll think about it
Thank you sir.Can you do with in a month because i am doing autopilot design and i have to simulate sir as my final year project
Hi
thank you for sharing this, I have to questions please, if I wan't to control the aircraft by the keyboard or a joystick, is it possible with the same options you chose ?
if I want to run this simulink file with external mode so I can link the simulator with a hardware model , is flightgear compatible with external mode?
Yes, it works with third party flight simulators,
You will have to use the 'Pilot Joystick' block in the Simulink Library Browser - Aerospace Blockset
Regarding the keyboard, I'm not sure, it might work.
Watch my old video on connecting joysticks to MATLAB,
ruclips.net/video/A7KkciHn0jc/видео.html
thanks a lot for responding
I have a robot that is connected to simulink using arduino , thats require external mode on simulink, is it compatible with flight gear?
Is joystick compatible with external mode?
I'm not sure about what external mode your talking about.
Compatible with flight gear? Yes
The only 'external mode', is that Pilot joystick block in Simulink Browser.
Watch my other video for a detailed explanation.
whenever an arduino is connected to matlab you have to switch the simulation mode from normal to external
so the hardware board are arduino
if i am going to use arduino and joystick at the same time
what board should I use?
I mean in the configuration parameters should I choose ardino or joystick?
and in the simulation mode, does the joystick work when the external mode is on ??
I haven't used arduino ever before, so unfortunately I am not sure.
Hey, Can you tell me how to add other variant subsystem in existing model when already a subsystem is working. I want to change Simulink 3D visualization to FlightGear visualization in my block diagram under visualization subsystem.
That requires C++ scripting, which is beyond my knowledge, sorry!
ok, thanks sir.
I am using Matlab 2019a with flightgear 2018.2.
My Simulink crashes when flightgear opens.
please help.
ruclips.net/video/b-hK5-4D5Rc/видео.html
Hi, have you the solution in matrix model in matlab 2019a? because when i try, the input value of the vector is error. please help.
Your videos have been very helpful for me, but I am having some problems with setting things up. Would it be possible for you to help me? I tried setting up a flight path similar to what you did here and connected it to FlightGear. But when I ran it, the aircraft did not move. Though something that I did different, was that I used the hl20 model.
Check your batch file
Maybe you did not connect the output mux block to the FlightGear sim block.
Are you able to run the simulation in MATLAB without FG?
The mux block is connected to the sim block, I tried copying the setup you have as close as possible. The MATLAB simulation does run, but when I used scopes to see the latitude, longitude, and altitude coming out of the FE to LLA block, lat/long do not change while altitude does. But also when I ran FlightGear from it, I noticed that after I entered in dos('runfg.bat') FlightGear would start and the simulation would load in, but the Command Window never brings up the >> for the next command.
Actually, I found out that the lat and long were changing, but by a very small amount. I believe the only issue is that the >> never comes back up, which makes me think there's some sort of loop, or error that's preventing it from completing.
I found a way to get the simulation to run with FlightGear, but when I do, the terrain suddenly disappears, and the aircraft floats in space. Would it be possible to get the simulink architecture you used in this demonstration? I would like to look through it to make certain I am doing things right.
Oh that problem is due to your latitude and longitude, they are written in opposite form, if you check or enable the HUD it should tell you.
That happened to be before as well.
Also check that you first installed scenery. The default FG only comes with San Francisco Bay Area.
P.S. My architecture is the exact same as what's in the video!
can you show how to connect live instead of explaining through slides ? I dont think this is understandable for beginners .
How To Connect MATLAB and Simulink to FreeFlight ??
No clue
MATLAB version is 2015a
That is the one I have, You can use FlightGear V3.0