Board index FlightGear Support Interfacing

MATLAB Send Problem

Connecting two computers, using generic protocol, connecting with Matlab?

MATLAB Send Problem

Postby realdream » Mon Oct 31, 2016 1:20 pm

Hello All,

I am trying to use C172 model in FlightGear in combination with MATLAB. The receiving flight information works flawlessly.

However, when I try to send data (e.g. sinusoidal elevator input just to try sending), something happens to simulator and aircraft crashes. I use the following .bat file for executing of the flightgear.

C:
cd C:\Program Files\FlightGear 2016.3.1

SET FG_ROOT=C:\Program Files\FlightGear 2016.3.1\data
.\\bin\fgfs --aircraft=c172p --fdm=null --native-fdm=socket,in,30,127.0.0.1,5503,udp --native-ctrls=socket,out,30,127.0.0.1,5505,udp --fog-fastest --disable-clouds --start-date-lat=2004:06:01:09:00:00 --disable-sound --in-air --enable-freeze --airport=LTBQ --runway=09 --altitude=7000 --heading=90 --offset-distance=0 --offset-azimuth=0

I tried the default ports, it did not work out, so I changed the input port, again same result.

Can anyone help me with this issue?

Kind Regards,
realdream
 
Posts: 2
Joined: Mon Oct 31, 2016 1:16 pm

Re: MATLAB Send Problem

Postby wkitty42 » Mon Oct 31, 2016 6:19 pm

can you be more specific about "something happens to the simulator and aircraft crashes"?? that's pretty open-ended...

the only other question i can think of is, are you updating the proper properties for the c172p? remember that not all craft may use the same properties for certain functions... taking the c172p as a "for instance", it has two different engines in place... depending on which one the craft is using at the time also depends on which properties are valid and can be altered...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04

Re: MATLAB Send Problem

Postby realdream » Tue Nov 01, 2016 7:33 am

Hello,

I was simply using wrong blockbox to send data to the simulator. That's why it crashes. However, this still not resolves my question.

My ultimate aim is to create an autopilot. Since I do not have enough time to model an aircraft, I require to use an available ones.

Therefore, my only intend to use FlightGear is to obtain the FDM into the MATLAB, make some calculations and send control data back to FlightGear.

However, I couldn't find how to do the latter part. I mean, I can get control data from FlightGear to MATLAB, but I cannot send control data from MATLAB to FlightGear.

Can you help me with this issue?

Kind Regards,
realdream
 
Posts: 2
Joined: Mon Oct 31, 2016 1:16 pm

Re: MATLAB Send Problem

Postby Johan G » Tue Nov 01, 2016 11:55 am

realdream wrote in Tue Nov 01, 2016 7:33 am:My ultimate aim is to create an autopilot.

[...]

[...] I can get control data from FlightGear to MATLAB, but I cannot send control data from MATLAB to FlightGear.

Can you help me with this issue?

I think that the FlightGear wiki article Interfacing FlightGear might be a good starting point.
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit

Re: MATLAB Send Problem

Postby arsalanr » Tue Nov 01, 2016 9:03 pm

hello every one
I'm using flight gear as interface with matlab. I just followed matlab Help and did all steps.
after running Simulink ,I enter this command in matlab command line (system(runfg.bat &)).then flight gear runs and shows the airplane but its static in a fixed state.
I think matlab doesn't send flight data to interface.
how can I solve it??
arsalanr
 
Posts: 1
Joined: Tue Nov 01, 2016 2:48 pm

Re: MATLAB Send Problem

Postby beghelli » Tue Oct 09, 2018 9:44 am

Hello, could you give more details about what you mean by "I was simply using wrong blockbox"? It is because I am facing the same problem now, but I haven't solved it yet.
Thank you.

realdream wrote in Tue Nov 01, 2016 7:33 am:,

I was simply using wrong blockbox to send data to the simulator. That's why it crashes. However, this still not resolves my question.

My ultimate aim is to create an autopilot. Since I do not have enough time to model an aircraft, I require to use an available ones.

Therefore, my only intend to use FlightGear is to obtain the FDM into the MATLAB, make some calculations and send control data back to FlightGear.

However, I couldn't find how to do the latter part. I mean, I can get control data from FlightGear to MATLAB, but I cannot send control data from MATLAB to FlightGear.

Can you help me with this issue?

Kind Regards,
beghelli
 
Posts: 1
Joined: Tue Oct 09, 2018 9:39 am

Re: MATLAB Send Problem

Postby wkitty42 » Wed Oct 10, 2018 2:04 am

@bwghelli: you do realize that this topic is two years old, right? also realdream's last visit was on Nov 04, 2016 4:10 am, also two years ago... they only made 2 posts in the time from the 1st to the 4th, too...
"You get more air close to the ground," said Angalo. "I read that in a book. You get lots of air low down, and not much when you go up."
"Why not?" said Gurder.
"Dunno. It's frightened of heights, I guess."
User avatar
wkitty42
 
Posts: 9146
Joined: Fri Feb 20, 2015 4:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 20.04


Return to Interfacing

Who is online

Users browsing this forum: No registered users and 2 guests