Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Matlab Unity real time interface

Discussion in 'Formats & External Tools' started by SantanelloJohn, Jan 19, 2012.

  1. SantanelloJohn

    SantanelloJohn

    Joined:
    Jan 19, 2012
    Posts:
    1
    I am trying to interface matlab with unity in a real time environment. Ideally I would like to be able to run a matlab .m file, and have it send data to unity based off matlab simulations, and have unity send back data to trigger specific events.

    I have a working program that uses the work of Kevin Bartlett to send data serially through a python interface (http://www.mathworks.com/matlabcentral/fileexchange/24418-pyudp)

    This works, but is not fast enough to work in real time. It takes too much for python to be opened each time a packet is transmitted and limits the frequency in which data can be transmitted significantly.
    I've been looking around to see if anyone has done any work in a related area, but have not found anything.

    Does anyone have any suggestions on how to approach the problem, or know of anywhere where someone has done something similar?

    Thanks for your help
    John
     
    anstone likes this.
  2. typane

    typane

    Joined:
    Nov 25, 2011
    Posts:
    297
    Can you keep a connection open through python so technically it won't close, it will just be sending empty packets with empty data. So when it needs to be used it doesn't have to be started up again. Not exactly sure what you are trying to achiever with it, although real time is always difficult. You may have to create some medium api to handle both segments that allows the constant of flowing packets without severing a connection. Get back to me if you find anything.
     
  3. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    969
  4. cherif90

    cherif90

    Joined:
    Feb 23, 2016
    Posts:
    1
    I need to integrate GA optimization of matlab with the game engine tool of Unity3D. Now what I need is to generate the solutions using matlab and send it to Unity3D. Unity3D will calculate the objective function and will return the results again to matlab in order generate the next solutions and so on. Is this process possible? If so, could you please support me with any information or documents that can guide my work?
     
  5. VRQiu

    VRQiu

    Joined:
    Feb 25, 2017
    Posts:
    1
    Hello cherif90, I have a similar question like you that I want to present the visual stimulus to Unity3D, and the participant would return a parameter. Then matlab send another stimulu to Unity3D. And if you had some solution method or documents, will you share with me? Thanks a lot. And my email is: yunda.qiu@qq.com.
     
  6. anstone

    anstone

    Joined:
    Oct 18, 2017
    Posts:
    1
    Hello everyone, I'm really interested in this topic since I need to estabilish a connection between the two softwares too. Are there any news about this? I'm basically trying to realize a driving simulator. Unity should send the selected gear to Matlab, which calculates the vehicle data with the torque and power curves and send it back to unity for the real time driving. On one hand Matlab is much more handy to intersecate curves and stuff like that, but on the other hand I recognize that the transmission frequency can be an issue. In the case no further improvements have been made on the communication, is there a way I can manipulate curves having just some arrays of experimental data?

    Thanks

    Andrea