(matlab coder) Unable to package?
Afficher commentaires plus anciens
When I try the following code for C++ class generation,It can be generated successfully, but it fails to be packaged, I get the following error, how can I solve it? your answer would be great appreciate.
open code generation report window and click "Package Code" button
- select "hierarchical" mode
File cholesky does not exist

- select "flat" mode
The "flat" mode has the following function rename conflict

For easy reproduction, my minimum code is as follows.
- Create a new "+SlamGraph2D" directory in the current working directory, and then design a MATLAB class file "slamFactorGraph.m" in this package directory with the following content:
classdef slamFactorGraph<handle
% generate c++ class for corresponding to matlab class
properties (SetAccess = private, GetAccess = public)
NumNodes
NumFactors
end
properties (Access=private)
graph
end
methods
function obj = slamFactorGraph()
obj.NumNodes = 0;
obj.NumFactors = 0;
obj.graph = factorGraph();
end
function addRelFactor2D(obj,nodeIDs,measurement,guessPoseXYTheta)
% nodeIDs = generateNodeID(obj.graph,1,"factorTwoPoseSE2");
f = factorTwoPoseSE2(nodeIDs,Measurement=measurement);% odometry
addFactor(obj.graph,f);
nodeState(obj.graph,nodeIDs(1),guessPoseXYTheta);% guess value
obj.NumNodes = obj.graph.NumNodes;
obj.NumFactors = obj.graph.NumFactors;
end
function optimizeFactorGraph2D(obj)
fixNode(obj.graph,0) % fix the start point.
optns = factorGraphSolverOptions();
optimize(obj.graph,optns);
end
function poses = getNodeState2D(obj)
ids = obj.graph.nodeIDs(NodeType="POSE_SE2");
poses = obj.graph.nodeState(ids);
end
end
end
- Then,Create a new "slamMapGraph2D.m" entry-point function file in the current working directory with the following contents.
function poses = slamMapGraph2D(measurement,fromID,toID,guesspose)%#codegen
%% custom factor graph
fg = SlamGraph2D.slamFactorGraph();
fg.addRelFactor2D([fromID,toID],measurement,guesspose);
fg.optimizeFactorGraph2D();
poses = fg.getNodeState2D();
end
- Finally, use the following command to generate the C++ class, it succeeds, but the packaging fails
cfg = coder.config("lib","ecoder",true);
cfg.FilePartitionMethod = "MapMFileToCFile"; % 为每个文件生成C/C++文件,这样方便独立于slamFactorGraph.h,slamFactorGraph.cpp生成使用
cfg.Toolchain = "CMake";% since R2023a,Generate generic CMakeLists.txt file
cfg.GenerateComments = false;
cfg.GenCodeOnly = true;
cfg.CppInterfaceStyle ="Methods";
cfg.TargetLang = 'C++';
cfg.CppInterfaceClassName = 'myGraph';
cfg.InlineBetweenUserFunctions = 'Readability';
cfg.InlineBetweenUserAndMathWorksFunctions = 'Readability';
cfg.InlineBetweenMathWorksFunctions = 'Speed';
measurement = [1,2,3];
fromID = 1;
toID= 2;
guesspose = [1,2,3];
codegen -config cfg slamMapGraph2D -args {measurement,fromID,toID,guesspose} -lang:c++ -report
my env:
ubuntu 20.04
matlab 2023a
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Localization Algorithms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!