Best method of integrating provided C++ API for robot in MATLAB/Simulink
1 回表示 (過去 30 日間)
古いコメントを表示
Hi There,
Until recently I've been using ROS on a Linux setup to communicate with the robot in my lab but due to the addition of some extra hardware being added to the system (which I only have windows drivers for) and some inconsistant control-loop frequency issues with ROS I am now looking to make the switch to running everything on windows. I want to remain within the MATLAB/Simulink environment as much as possible as all my control logic is created within Simulink. While running on Linux I would simply publish any torque commands using the publisher block in Simulink and similairly use the subscriber block when reading measurements of the robot. All the ROS files were a wrapper for the API created by the manufacture for communicating with the robot. I am now looking to call functions, written in C++, within the Simulink environment.
The manufacture has provided the header files and librairy files for the robot's API. I need to integrate the functions within the header files into my control architecture. After some research I think that my best option would be to bring the parts of the provided C++ API from the manufacture into Simulink using an S-Function. My question is which type of S-Function would be best suited for me based on the following criteria? I have seen there are different options such as the Legacy Code Tool, S-Function Builder, C MEX S-function & Level-2 MATLAB S-Function.
- Need to be able to print information from the C++ code to either cmd or command window (I think the later is my better option, prehaps using the mexPrintf() function).
- S-Function only has access to the header files and and library files, not the source code for the included API functions.
- Not sure if this is important but communication between the API and the robot is done over USB.
From what I've gathered I think my best option is either a C MEX S-Function or using the S-Function Builder. I've been experiementing with the S-Function builder but am unable to solve my first criteria using mexPrintf(). Not sure if this method of creating an S-Function allows for the use of mexPrintf()?
EDIT: I realized the mexPrintf() is actually working, it has been printing to the diagnostic window as opposed to the command window.
Thanks in advance for any advice you can offer.
2 件のコメント
Darshan Ramakant Bhat
2021 年 7 月 1 日
Based on your requirement I guess you can explore following options ;
C/C++ S function - https://www.mathworks.com/help/simulink/c-c-s-functions.html
snow John
2024 年 1 月 10 日
Hello sir, have you solved your problem yet?
I have a similar problem How to utilizes APIs provided by robot manufactures and then control the robot - MATLAB Answers - MATLAB Central (mathworks.cn).
If you have any suggestion, pleased let me know
Best,
-Jian
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Publishers and Subscribers についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!