Is it possible to use simulink coder incompatible robotics toolbox functions using S-functions?

1 回表示 (過去 30 日間)
Hi,
I am trying to develop a stand-alone ROS node in simulink that utilizes the robotics toolbox matchScansGrid() function.
But as simulink coder does not support code generation for the matchScansGrid() function (or any of the lidarSLAM tools), I was proposed an alternate method to use the matchScansGrid() in simulink:
  1. Make a matlab function {eg testScanMatching() } that utilizes (or calls) the matchScansGrid().
  2. Generate C code of this function (testScanMatching) using Matlab coder. This is possible as matchScansGrid() is supported by matlab coder.
  3. Use the packNGo functionality
  4. Unzip the output of step 3.
  5. Use the legacy code to generate a compatible S-function (of testScanMatching)
  6. Import it in simulink
Question:
  1. Does this method work? Can I really use matchScansGrid() in simulink using this round-about way?
  2. Is there a guide to implement S-functions from matlab coder generated C/C++ code ?
Thanks in advance.
note: I am testing this method but currently I have trouble building an S function from the code generated of testScanMatching
  2 件のコメント
Denis Gurchenkov
Denis Gurchenkov 2019 年 9 月 13 日
If you just put the use of matchScansGrid into a MATLAB Function block, that should work fine in Simulink Coder. E.g. have a block with four inputs and one output, like this:
function relPose = useMatchScansGrid(ranges1, angles1, ranges2, angles2)
x = lidarScan(ranges1, angles1);
y = lidarScan(ranges2, angles2);
relPose = matchScansGrid(x,y);
end

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

採用された回答

soorajanilkumar
soorajanilkumar 2019 年 9 月 16 日
Thanks Denis,
It worked now.
I'm not sure, but when I tried before I was not successful. In addition I had to enable dynamic memory allocation to generate code for the matlab function.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCode Generation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by