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.
  1. 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).
  2. S-Function only has access to the header files and and library files, not the source code for the included API functions.
  3. 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.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Publishers and Subscribers 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by