simulink: custum code not detecting header file.

5 次查看(过去 30 天)
I created a matlab function and converted it to c++ code using the matlab coder(matlab function below:).
function [s1, s2] = factorGraphTest() %#codegen
G = factorGraph;
fctr = factorTwoPoseSE2([1 2], Measurement=[1 1 0]);
addFactor(G,fctr);
fixNode(G,1,true);
optns = factorGraphSolverOptions(MaxIterations=1000,VerbosityLevel=2);
optimize(G,optns);
s1 = nodeState(G,1);
s2 = nodeState(G,2);
end
My intention is to then call this function in simulink on hardware. I made sure to add the relevent files in the in the custom code section of the configuration parameters:
Include headers:
#include "factorGraphTest.h"
Include directories:
"C:\Program Files\MATLAB\R2022b\extern\include\" C:\Users\Blue\Desktop\debug\build\initalizationScripts\onlineSLAM\codegen\lib\factorGraphTest\
Source files:
factorGraphTest.cpp
However I'm receiving the following error when validating the custom code:
What's strange is that this file is located at "C:\Program Files\MATLAB\R2022b\extern\include\ceres\" and simulink should be able to find the file based on the infomation provided in the Include Dirctories. Is there an addtional step I might have failed to consider?
  1 个评论
Sarvesh Kale
Sarvesh Kale 2023-4-19
编辑:Sarvesh Kale 2023-4-19
Hi Daniel Delannes-molka,
I can suggest a workaround for this, follow the following steps, if you want your generated code to run on hardware
  1. generate code for simulink model targetting a hardware.
  2. after the code generation, an model_ert_rtw folder must be generated, inside that folder copy paste your source file and header file, in your case factorGraphTest.cpp and factorGraphTest.h, also their dependencies
  3. Once the files are copy pasted in the folder, you have to edit the model.c generated file, at the top of file do your file inclusion and Cpp file inclusion and in the step function call your function factorGraphTest in places you wish
  4. compile the source code using gmake on matlab command line, make sure you are in the ert_rtw folder where the code is modified, !gmake -f model.mk clean followed by !gmake -f model.mk
  5. if everything compiles then the hex file will be generated one level up from your ert_rtw folder
I hope this help, make sure to include both your factorGraphTest.c and factorGraphTest.h file otherwise the liker will throw an error
Thank you
Sarvesh kale

请先登录,再进行评论。

回答(0 个)

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by