Matlab interface?

martins

Orbiter Founder
Orbiter Founder
Joined
Mar 31, 2008
Messages
2,448
Reaction score
474
Points
83
Website
orbit.medphys.ucl.ac.uk
I am currently having some fun implementing an interface between Orbiter and Matlab using the Windows DDE protocol.

As an example, here is a visualisation of a few vessel orbits extracted from orbiter in real time:

matlab1.gif


My question (which I think I've asked before): How useful would such an interface be for the orbiter community in general? I realise that matlab is too expensive to use for a hobby, so probably only people who are using matlab anyway will be able to benefit from this, but on the other hand, this could offer quite a few interesting possibilities, such as using matlab for trajectory optimisation, offline calculations, visualisation, general numbercrunching, etc.

Also, how compatible are the free Matlab alternatives (scilab, etc.)? I am not planning on using anything sophisticated, and no toolboxes, so there may be a good chance of being able to port the interface. The only requirements would be DDE support, and (probably) the ability to use mex files compiled for matlab, (or alternatively to compile mexfile equivalents from the same sources). Anybody with experience regarding this?
 
My experience with Matlab involves stand-alone programming only, no interfaces, so I can't speak with authority, but Matlab could be a great tool for offline planning and analysis. Personally I am more comfortable with Excel VBA, but I don't know if an Excel interface is possible.
 
Though I have less experience in this area than most politicians have brain cells...I'd recommend if you went that route that you also make it compatible with Scilab just because it's free and available to more users.
 
Personally I am more comfortable with Excel VBA, but I don't know if an Excel interface is possible.
It depends on if the interface Martin is developing acts as a DDE client or server. If it acts as a server, I can't see any reason why Excel couldn't connect to it and request data.
 
that is a really pretty picture martins, perhaps I am missing something so I am going to ask the mr. dummy question... can u tell me why I would want to do that myself?
 
It depends on if the interface Martin is developing acts as a DDE client or server. If it acts as a server, I can't see any reason why Excel couldn't connect to it and request data.
Currently, Orbiter is the server, and matlab is the client. That is, matlab requests data from a running orbiter session. I would however like to also implement an interface in the opposite direction, so that orbiter can connect to a matlab session to request offline calculations, e.g. use matlab to calculate the burn times for a transfer orbit. I haven't checked in the DDE documentation yet, but I guess there is no reason why an application couldn't work simultaneously as a server and client.

Presumably, any application that can work as a DDE client could connect to orbiter's DDE interface, as long as it can send its requests in a format that orbiter understands. For example, orbiter expects all data to be sent in text format over the clipboard. Text format should be the most generic, so hopefully will be supported by all DDE-enabled applications.
A typical request string would be

'get_vesselid,1'

(return a handle for the first vessel in orbiter's vessel list), or

'get_state,#id'

(return current vessel state for a vessel with the provided handle). Note that all this is very preliminary, since I wrote DDE interface, as it stands now, late last night. It may need a bit more work. :)


-----Post Added-----


that is a really pretty picture martins, perhaps I am missing something so I am going to ask the mr. dummy question... can u tell me why I would want to do that myself?
Well, the general idea was to use matlab for things like

trajectory optimisation, offline calculations, visualisation, general numbercrunching, etc.
Even if you don't have use for pretty pictures, you still might use matlab (or a similar application) to do calculations for you, which you could then use for either offline analysis, or feed them back into orbiter to perform burns etc.

If none of these possibilities appeals to you, you can also safely ignore this feature altogether with no adverse effects. :lol:
 
Irnenginer, one of the Project Apollo - NASSP guys is using Scilab for state vector calculations etc., but he didn't try to do an interface to Orbiter yet: http://www.ibiblio.org/mscorbit/mscforum/index.php?topic=1825.msg16412#msg16412

:speakcool:

As Tschachim mentioned I have used Scilab for doing calculations for NASSP (I had used MATLAB early on but switched over because Scilab is open source). I knew MATLAB had this capability and I believe that Scilab has similar functionality. I am not programming savvy enough to have ever tried it myself but felt that it could be useful at least for what I was doing.

As far as usefulness I think it would open up a lot of possibilities for navigating in orbiter.

While Excel has its use its accuracy is rather poor as well as its mathematical capability, making it rather slow for complex calculations.
 
It would be very cool if one could predict sophisticated maneouvres thanks to some scripts (we're counting on you :) )

Portability
I have some experience with both Matlab and Scilab, and I can say that pure scripts can be ported with some effort. It's things like != (Matlab) and <> (Scilab) for not equal to etc, little things like that.
There are even Matlab to Scilab Conversion Tools that are supposed to do this automatically.

DDE
Quick googling tells that DDE was added in version 3 of Scilab in 2005.

http://ralyx.inria.fr/2005/Raweb/scilab/uid94.html

"DDE (Dynamic Data Exchange) client functions have been added to the Windows version. It allows communication with other Windows application supporting this communication (Word, Excel, ...)."


The current version is number 5.

I can't seem to find more information on DDE though... I hope it hasn't been abandonned. I'll report back when I'm on Windows.
 
I am thinking that this could be used for a really in-depth simulation of stuff we usually don't consider, such as sensor data and ground software functions.

For example, you could Matlab or Excel to generate star tracker or sun sensor data for a spacecraft and introduce noise into it, which can get uploaded to Orbiter for processing by an MFD to determine vehicle attitude estimation, which can then be downlinked back to the external application, which performs the mission control function of planning the next maneuver based on this imperfect attitude (as opposed to the internal "perfect" attitude). The resulting maneuver will have realistic dispersions in it which the Orbinaut will have to factor into his flight plan, just as real spacecraft crews and operators must.

For added realism, forgo use of the Orbit MFD and use only orbit data generated by radio-ranging and calculated off-line, for added realism...

Of course, this would be hard-core realism, and not as much fun as just jumping in and getting instant data. Real life flight is seldom as exciting as simulations.
 
actually u got a point andy.... I do forget that when in space, noone can hear you scream, er i mean you don't have instant access to your orbit, or Long/Lat like the mfd's that orbiter provides you right away...

If I was on the ground (in the sim) and I was part of mission control for a manned or unmanned mission... It would be nice to tell my Ummu's when to burn and what orientation to get em to the moon etc....

I am thinking now that I could also use such a tool to get a satellite in geosync orbit over a specific place on the planet
 
LOL you know you are an Orbiterhead when you refer to flight crews as "my UMMUs".

In order to do it right you'd have to do all maneuvers, including rocket launches, "blind", using only the last known data interpolated to the present. After the maneuver/launch is complete you would have to gather range data from whatever ground stations are in view (or simulate GPS data somehow), crunch that data to calculate your orbit, and figure out how well your maneuver performed, which could take hours of sim time to do. That slow, deliberate process is why real space missions seem to do things a lot slower than we do in Orbiter.
 
My question (which I think I've asked before): How useful would such an interface be for the orbiter community in general?

I would say yes. Lot's of schools/universities offer the use of Matlab anyway (at least they did in my case), so it's not at all expensive for a lot of people.

At least keeping DDE support would be good.

BTW, wasnt't DDE supported earlier? I remember trying out DDE with Orbiter a long time ago, by writing a Delphi win32 application that was able to extract some data from orbiter using this? Though I remember it wasn't much data, or even documented (I think I used some DDE info from the old ESA presentation for Orbiter).

regards,
mcduck
 
I agree, sounds great. It does sound like it could be an interesting alternative to something like satellite tool kit (which I am attempting to learn). MATLAB is a great language for things of this nature, quite interested here. :)
 
Back
Top