Can't run a import FMU, modelDescription.xml is not found

9 views (last 30 days)
songyue zheng
songyue zheng on 3 Jun 2021
Answered: Wenhan Huang on 2 Aug 2021
i was trying to import a FMU from the other tool into Simulink.
i can see that my cm_FMU folder has been generated under slprj\_fmu folder, and there is modelDescription.xml under cm_fmu folder.[D:\Program Files\Polyspace\R2020b\slprj\_fmu\8ae35f333694fdbb35d722538d0fc9e8\cm_FMU]
but when i start the simulation. following error message popup.
Error in supplied FMU: An error occurred in function 'fmi2Instantiate' for block 'fmudemo_cm/Subsystem/FMU' during simulation. To view debug logs, open FMU log file. For more information, see the FMU troubleshooting documentation.
Debug Logging enabled for block 'fmudemo_cm/Subsystem/FMU' Log from FMU: [category:error, status:fmi2Error] Can't find D:/Program%20Files/Polyspace/R2020b/slprj/_fmu/8ae35f333694fdbb35d722538d0fc9e8/cm_FMU/modelDescription.xml
so what is going on there, any other steps need to be done?

Answers (2)

Seungbum Koo
Seungbum Koo on 25 Jun 2021
It looks like MATLAB cannot find the file you mentioned. Although the file exists, MATLAB cannot find it if the file is not in the known path.
Can you load the file from the MATLAB command line?
DOMnode = xmlread('D:\Program Files\Polyspace\R2020b\slprj\_fmu\8ae35f333694fdbb35d722538d0fc9e8\cm_FMU\modelDescription.xml')
If it works, then it means the file exist but MATLAB does not know where it is. So you should tell MATLAB that when asked to find files, look into that folder as well.
To add the path to that xml file to let MATLAB to be able to locate it, you can do the followings:
% To add the path to the file
oldpath = addpath('D:\Program Files\Polyspace\R2020b\slprj\_fmu\8ae35f333694fdbb35d722538d0fc9e8\cm_FMU');
% do whatever work you need to do
% To remove the added path
If there are other files in other subfolders in the same project (I assume slprj stands for sl project), you can do the following to add all of the subfolders under D:\Program Files\Polyspace\R2020b\slprj by doing the followings:
oldpath = addpath(genpath('D:\Program Files\Polyspace\R2020b\slprj'));
% do whatever work you need to do
Place addpath before the loading occurs. It will fix the problem.
Note: addpath is effective only in that session. If you turn off MATLAB and launch it again, you have to add it again.

Wenhan Huang
Wenhan Huang on 2 Aug 2021
Hi Songyue,
I suspected that the FMU doesn't handle uri nicely, likely due to %20 there. Do you want to run the FMU under any path without space?





Community Treasure Hunt

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

Start Hunting!