Matlab C Coder gives error for cloning object
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, i am trying to clone my trackergnn object but the coder gives me this error
Undefined function or variable 'loadObjectImpl'.
It works well on matlab code but when i am trying to convert it to C code with coder it gives this error.
Coder does not give an error for functions like saveObjectImpl but loadObjectImpl. Why is that ?
0 Commenti
Risposte (1)
Matan Silver
il 26 Apr 2022
Hi Anil,
It looks like loadObjectImpl is not in the list of officially supported functions for System Objects (trackerGNN is a System Object):
If you are ok with the System Object being loaded at codegen-time and not run-time of the generated code, you may be able to use "coder.load" to load the information from the MAT file:
However, without more information about your use-case and what the code looks like, it's hard to say if this solution would work for you. Would you be able to upload some simple reproduction files and a script to call codegen on those files and trigger the error? This could help figure out if there's a different viable workaround.
Matan
3 Commenti
Matan Silver
il 29 Apr 2022
Hi Anil,
After some more investigation and discussion with my colleagues, I have some more information for you:
- It looks like the "clone" method on system objects is not supported for code generation. Note in the MATLAB Documentation page for "clone", there is no "Extended Capabilities" section for C/C++ code generation support: https://www.mathworks.com/help/matlab/ref/clone.html . Usually the absense of such a section in the doc indicates code generation is not supported.
- You can actually also see that in this implementation for cloneImpl, the "loadObjectImpl" method is being called. This method is not on the list of system object supported methods for code generation, and this is probably why you are receiving this particular error message: https://www.mathworks.com/help/coder/ug/use-system-objects-in-matlab-code-generation.html
- If you need more than one trackerGNN object at runtime in your generated code, I think the idiomatic way to do this would be to instantiate more than one object to begin with, instead of cloning an existing object. Unfortunately limitations in system objects and code generation prevent supporting "clone" for code generation, for now.
Could you describe a bit more why you need to use the "clone" method? Perhaps there might be another workaround (besides instantiating more than one trackerGNN) which could be applied, depending on the reasons you need to copy a trackerGNN with all of its state at runtime in generated code.
Hopefully this helps a bit, and feel free to reply if you have more questions or info. Thanks,
Matan
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!