|
From: Philippose R. <sa...@ro...> - 2006-02-20 17:37:29
|
Hi again,
Hope you all had a great weekend! I spent Sunday
trying to come up with a proof-of-concept solution for
the Matlab-JSBSim interface.
I decided to work first at the Matlab level and
keep the S-Function Simulink level for later, once its
clear whether this whole thing is possible or not.
Basically, I wrote a Matlab MEX file in C and
compiled it into a DLL (as MEX files are compiled in a
Windows environment), which contains multiple
functions doing the following:
1. Create a socket given a port number and put it
into listen mode (For the data sent out by JSBSim)
2. Delete a socket given the base socket (and the
accepted socket if there is one) ID
3. Connect to an already existent socket given the
Host IP and Port number(To interface with the FGInput
socket opened by JSBSim)
4. Send data to a Socket (using which I can "hold"
and "resume", etc...the JSBSim simulation)
5. Receive data from a socket (In order to collect
the data sent out by JSBSim)
Functions 1-4 are working fine as of
now...ofcourse, there is room for improvement on the
user friendliness (read..help/usage documentation),
but I am able to do all those functions, and control
JSBSim from within matlab.
Function 5 is partially working in the sense..the
socket and data collection part of it is working, but
I was having trouble with the string buffer
overflowing and causing a segment fault in
Matlab...but that was already late into Sunday evening
:-) And I decided to debug it over the course of this
week.
Jon, I was thinking...now that its more or less
clear that this is possible...do you think it would be
possible for you (ofcourse...anyone else is welcome
too) to consider creating a similar interface as
FGOutput also on the input side...where you can
specify in the XML file what data for the simulation
comes from outside, and accept a string of comma
separated values and assign them to the right
variables during simulation? Basically...like shifting
the FCS outside.
Then, once I start on the S-Function interface, it
will be a complete closed loop system...a
co-simulation. And as for the realtime plotting of
Simulation data...that will come naturally once the
Simulink S-Function interface is up...because realtime
plotting can be done in Simulink.
One more question....does JSBSim work with a fixed
time step during the simulation...or does it use a
variable time step solver...?
And...also...is it by anychance possible to drive
the JSBSim simulation from outside...as in...supply
the time steps from say..Simulink? (Basically...for
synchronization between the two systems)
Anyway...now time for driving lessons (ya...my
Indian license is not valid here in Germany...so need
to do it all over again :-)!)
Have a great day!
Regards,
Philippose
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
|