Simulink/SimscapeMultibody, using UDP in parallel, without blocking a simulation?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (1)
Vasco Lenzi
el 11 de Nov. de 2020
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 comentarios
Vasco Lenzi
el 11 de Nov. de 2020
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.
Ver también
Categorías
Más información sobre Model Preparation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!