Hello everyone,
Background:
Set Up:
I am working on a 64bit Windows 10 Pro system with Matlab 2021a and MingW 9.0.0
Related topics:
Problem:
The C++/Python library I am trying to use has many intenal functions. Starting with sending initial files to the robot and also the whole TCP/IP communication, which is not well documented and still not completely understood by me. It is very easy to write a c++/python/matlab code for reading the data of the robot and sending back commands when using the libraries functionality, even for a person like me who is not that versatile in c or c++.
I would therefore like to have a Simulink project with a fixed, discrete step size solver that runs a program/function in each time step to read the data into Simulink such that I can work with it and later on send it back using another program/function. The program/function should call the Python/C++ library.
I understood, that Simulink can not simply generate C code when there is C++ or Python code in form of a Matlab-function block and that the usage of coder.extrinsic is at some point necessary, but I am still curious if there is some way of achieving what I would like to have.
I also read through the .mex file thread but have to admit that I don't completely understand their usage. For the topics of using Python or c++ libraries this might be true also, but I can not say that for sure, since all attempts with ry.[function] and coder.extrinsic('function') either failed in the code generation or binding process (especially when I tried to call a constructor in Python). I have not tried the C++ approaches since I didn't understand how to do that and I didn't find similar approaches.
Problems with the library might be, that the library includes a communication frequency, while simulink has it's own solver and the tcp/ip connection, that is somehow already implemented in Simulink but maybe in another way. (The library uses the boost library for this).
Question:
Is it possible to use either a whole Python or C++ library in Simulink or call programs that are written in these languages and which are calling these libraries and generate a simulink block that is being executed in each time step and that is still suitable for code generation? This also includes calling constructors in both languages.
Note:
I would have really liked to present you some code, but I after a few useless attempts I am now just trying to find out if what I am trying to do is even possible.
Thank you for reading this and also thank you in advance for any useful hint.