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 CenterFile Exchange에서 Code Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by