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

回答 (1 件)

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
Vasco
  2 件のコメント
David Brodmann
David Brodmann 2020 年 11 月 11 日
Dear Vasco
Thank you very much for the response, I will definitely try it out. The shared memmory block sounds really interesting, the project you linked seems to be written in C# though ? but I will research the shared memmory workflow. I am not sure the concurrent execution really works though, the experiences with Simscape Multibody and concurrent calculations are not the best to be honest.
Thank you very much for the reply.
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeModel Preparation についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by