- generate code for simulink model targetting a hardware.
- 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
- 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
- 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
- if everything compiles then the hex file will be generated one level up from your ert_rtw folder
simulink: custum code not detecting header file.
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
Sarvesh Kale
le 19 Avr 2023
Modifié(e) : Sarvesh Kale
le 19 Avr 2023
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
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
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!