MATLAB Answers

Simulink/S​imscapeMul​tibody, using UDP in parallel, without blocking a simulation?

조회 수: 2(최근 30일)
David Brodmann
David Brodmann 2020년 11월 5일
댓글: Vasco Lenzi 2020년 11월 11일
Dear fellow Matlab users
I am creating a model in Simscape Multibody trying to simulte close to realtime. For communicating with a c++ application I am using a udp receive and send block.
The problem is that the udp blocks tend to slow down the simulation drastically. The good thing is they are not necessary for the simulation to function, they are only needed to transfer the data. So from the architecture side is absolutely possible to provide the data with the simscape simulation and transfer them in a separate thread with udp.
The question is now, how do I implement a parallel udp communication in Matlab Simulink? is it possible to deploy some data in a global space and transfer them with a separate udp communication block? can I run both in parallel in one simulation ?
I am asking because it is really hard to find some usefull information on this and I have to say I am a bit frustrated on the general topic of parallelism in Matlab. But maybe it is just that I did not fully get it yet, so I would be glad of any help on the topic.
Thank you for you time
kind regards


Vasco Lenzi
Vasco Lenzi 2020년 11월 11일
I'm not sure you can because of the nature of the UDB block, but you can try follow this workflow:
if you have good knowledge with C++ you can implement a shared memory block in C++ that writes directly to the C++ application, there is a similar example here:
hope this helps
  댓글 수: 2
Vasco Lenzi
Vasco Lenzi 2020년 11월 11일
Yes the project is in C# unfortunately, but I thought it could serves as an inspiration.
You can write and/or embed native C++ in Simulink:
You could create a custom way of communicating through some shared memory.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by