Board index FlightGear Development Aircraft

Send data from Simulink to FlightGear as UDP

Questions and discussion about creating aircraft. Flight dynamics, 3d models, cockpits, systems, animation, textures.

Send data from Simulink to FlightGear as UDP

Postby arghyanir.giri » Tue Sep 08, 2020 9:56 pm

Hello everybody!
I have a parameter (wingspan) in my simulink model which needs to vary during the simulation. The FDM Package block doesn't have any parameter like wing-span to send it over to flightgear so i read into the documentation regarding using generic protocols, but i see no link with matlab or simulink anywhere. I managed to create a new property but i have to manually change it from internal property browser from flightgear. I want it to change from simulink. Also how do i initialize a property at the very beginning of the simulation. Like when the sim is paused..it shows the aircraft with no wings since the wingspan property is set at 'none' i want it to launch with value 1. Also even if i edit the runfg.bat with generic protocol command, how do i send it through simulink, the UDP send block?
Any kind of help is appreciated. I have received tremendous help from this forum regarding how to import a custom CAD into flight gear and how to increase the wingspan. This is the last phase. It would be really great if i could have some help with this since i have tried reading the documentation repeatedly but i cant seem to understand much since i am not actually a developer.
Thank you in advance!
arghyanir.giri
 
Posts: 9
Joined: Wed Aug 19, 2020 3:30 pm

Re: Send data from Simulink to FlightGear as UDP

Postby wkitty42 » Wed Sep 09, 2020 2:01 pm

how does simulink change other properties? the process should be the same... just figure out where to tell simulink about your new property and what value it should have when...
"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: 6542
Joined: Fri Feb 20, 2015 3:46 pm
Location: central NC, USA
Callsign: wk42
Version: git next
OS: Kubuntu 14.04.5

Re: Send data from Simulink to FlightGear as UDP

Postby enrogue » Wed Sep 09, 2020 2:16 pm

You should be able to initialise a property on the command line with --prop

--prop:[type:]name=value
Set the property name to value. You can optionally specify the property type by setting type to string, double,
float, long, int or bool.

When sending updates to the property via UDP, you should just include it in your protocol description for flightgear - sorry no idea what you do on the Simulink side
User avatar
enrogue
 
Posts: 250
Joined: Mon May 19, 2014 6:40 pm
Location: London (UK)
Callsign: enrogue
OS: Ubuntu, macOS

Re: Send data from Simulink to FlightGear as UDP

Postby arghyanir.giri » Sat Sep 12, 2020 11:20 pm

Hey enrogue! Thank you for your reply. The initialisation works perfect. Can you let me know how do you include the updates to the property in my protocol description? i have mentioned the property node as a chunk as described in the documentations, other than that?
This is my protocol file
Code: Select all
<?xml version="1.0"?>
-<PropertyList>
-<generic>
-<input>
<line_separator>newline</line_separator>
<var_separator>tab</var_separator>
-<chunk>
<name>wing-span</name>
<node>/controls/flight/wing-span</node
<type>double</type>
<format>%f</format>
</chunk>
</input>
</generic>
</PropertyList>
arghyanir.giri
 
Posts: 9
Joined: Wed Aug 19, 2020 3:30 pm

Re: Send data from Simulink to FlightGear as UDP

Postby enrogue » Mon Sep 14, 2020 12:49 pm

If you have simulink set up to send data via a generic UDP connection then your protocol file has to match the format that simulink is sending in

The above looks like text format (there is also binary)

you would put your protocol file (say as wingspan.xml) in $FGDATA/Protcols

you would then add the command line option for fgfs that receives the protocol - your simulink setup may have already put some input in (sorry I've not used simulink, just peeked at the website instructions for 30 sec)

something like

--generic=socket,in,10,,6652,udp,wingspan

see the following from $FGDATA/Docs/README.IO:

Generic Communication:

--generic=params

With this option it is possible to output a pre-configured
ASCII string or binary sequence using a predefined separator.
The configuration is defined in an XML file located in the
Protocol directory of the base package.

params can be:
serial port communication: serial,dir,hz,device,baud,protocol
socket communication: socket,dir,hz,machine,port,style,protocol
i/o to a file: file,dir,hz,filename,protocol

See README.protocol for how to define a generic protocol.

You'll really have to take a look at how simulink is sending the data (is it the same connection as the FDM data or an addtional connection?) and what format it's sending it in

edit: s/genetic/generic :D
User avatar
enrogue
 
Posts: 250
Joined: Mon May 19, 2014 6:40 pm
Location: London (UK)
Callsign: enrogue
OS: Ubuntu, macOS


Return to Aircraft

Who is online

Users browsing this forum: No registered users and 4 guests