1

I know my title is probably not the best description of what I am attempting to do, but let's see if I can't explain my situation a little better here.

Basically, what I am trying to achieve is attaching a Simulink model which, when run generates a set of data which I want to display in a graphical interface. I did not make the Simulink model myself, nor have I worked with Simulink before, so I am wondering what the best way to do this would be. The data can change in real time, and I want the display to update with it in correspondence with the output data. This will eventually be used for a game which the user is supposed to control, so the live feedback should be accurate and with minimal delay.

Ideally, if I were making a game I would code the entire thing in either C++ or Java, but the input device we are using to collect the data is dependent on the simulink module for processing the data from it.

I have looked at this from another similar question (Access/Call Simulink from Python):

http://simulinksimserv.sourceforge.net/

It is a server for transmitting the data via XML file, but I am wondering if there is a simpler way to get the data from Simulink into a graphics application written in Java/C/C++/Python that doesn't have the overhead of a server like SimServer.

Any and all suggestions are appreciated.

Community
  • 1
  • 1
hetoan2
  • 226
  • 4
  • 14

2 Answers2

2

I would also say that it depends almost entirely on what the graphics application is.

My current thoughts about this (i've been thinking about problems roughly along the same lines) is that one option would be to code an sfunction which opens a udp (or tcp) socket connection to the graphical display program, and transmits data across the socket in each simulation cycle. The sfunction block would then accept whatever data is minimally necessary to define the state which is being visualised.

This does however require the existence of both a pre-defined graphical visualisation and the ability to customise said visualisation to the extent of adding the socket connection to recieve the data. If you know a easy and powerful program which can do this, I would be interested to know!

1

I think it depends to a large extent on the graphical interface you intend to use to display the data. For example, the Aerospace Blockset has a native interface to FlightGear, but this is obviously geared towards flight simulators.

An alternative is to use Simulink 3D Animation to output the data from Simulink model to a VRML world for animation. However, this requires you to create the said VRML world outside of Simulink and is not that straightforward. Having said that, it's probably the most generic animation route from Simulink.

Finally, if you are looking at a 3D mechanical system simulation, SimMechanics has some decent visualization capabilities, including the possibility to import CAD models (and graphics).

If it is a custom graphics program you are talking about, then you will probably have to write an S-function to interface Simulink to the graphics program. That is also quite an advanced manoeuvre, which requires in-depth knowledge and understanding of how Simulink works.

am304
  • 13,758
  • 2
  • 22
  • 40