Search code examples
pythonhyperlinksimulinkblender

Linking Data between Simulink and Blender


I've been trying to determine a way to link data between a running Simulink model and Blender (or Python). I have no idea where to start on this, but I did find one piece of software that might've solved it, if I could get it to install correct; SimServer.

I found out about SimServer on StackOverflow (the original question is here), however I cannot get it to install correctly, it errors out during mex in the httpwrapper.c file stating that "syntax error; found SOCKET' expecting}'" (same if I remove the httpwrapper.c file from the mex command, it'll error out on another file the same way).

Is there a way to remedy this, or should I move on and try to find another solution? I feel as if another solution would be preferable and probably easier to install onto other machines. Is there someway I can pipe information from a running Simulink model to a file and have Blender/Python watch that file for changes and update a model in Blender Game in real-time?


Solution

  • If you are interested in writing data to a file from Simulink there are several ways to do that. I think the Easiest way would be to use add_exec_event_listener to add a callback listening to 'PostOutputs' event of your block. Within this callback you access data from block and write to a file.

    You can find doc for add_exec_event_listener at http://www.mathworks.com/help/simulink/slref/add_exec_event_listener.html

    Other ways to write to file from Simulink are

    1. Using MATLAB Function block. Use your own "extrinsic" function to write to file.
    2. Write S-Function in MATLAB or C/C++.

    From the external program you can watch this file for updates. Having real-time in this approach is doubtful. There could be lags in writing to file in disk and for the other program to notice the changes.