KULeuvenNeuromechanics / PredSim

Generate predictive simulations of human locomotion
MIT License
27 stars 53 forks source link

issue with creating external function #124

Closed VDB-Bram closed 5 months ago

VDB-Bram commented 8 months ago

Before submitting a bug report, read the error messages in MATLAB. Some errors are there to inform you about inconsistent inputs for certain settings.

Describe the bug A clear and concise description of what the bug is. When running main in the master branch the external function needs to be created. During that process there is thrown an error which makes it not succeed in making the external function.

To Reproduce Steps to reproduce the behavior:

  1. Which script did you run? https://github.com/KULeuvenNeuromechanics/PredSim/blob/master/main.m
  2. What settings did you use? the generic settings, only changed S.OpenSimADOptions.compiler to 'Visual Studio 15 2017' and turn on the verbose mode.
  3. What kind of OpenSim model did you use? Link to generic model, attach specific model, or describe model (bodies, joints, coordinates) if it is confidential. The Falisse 2022 model provided with the code.

Log file The log files will tell us what the error is, and where it occurred. When running main.m, you can find a log file of each simulation in the folder S.subject.save_folder. The name of this file ends with _log.txt. If there is no log file, copy the MATLAB command window to a .txt file and attach that instead.

Initialising settings from "C:\GBW_MyPrograms\PredSim\Subjects\Falisse_et_al_2022\settings_Falisse_et_al_2022.m".
Using C:\GBW_MyPrograms\PredSim\OCP\IK_Guess_Full_GC.mot as initial guess.

Subject name: Falisse_et_al_2022
OpenSim model: C:\GBW_MyPrograms\PredSim\Subjects\Falisse_et_al_2022\Falisse_et_al_2022.osim

Start PreProcessing...

   Creating new external function...
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19044.
-- The C compiler identification is MSVC 19.16.27043.0
-- The CXX compiler identification is MSVC 19.16.27043.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/GBW_MyPrograms/PredSim/opensimAD/buildExpressionGraph/F_Falisse_et_al_2022
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework 
Copyright (C) Microsoft Corporation. All rights reserved. 

  Checking Build System 
  Building Custom Rule C:/GBW_MyPrograms/PredSim/opensimAD/buildExpressionGraph/CMakeLists.txt 
  F_Falisse_et_al_2022.cpp 
C:\GBW_MyPrograms\PredSim\opensimAD\OpenSimAD-install\sdk\include\OpenSim/Common/Component.h(2123): warning C4068: unknown pragma [C:\GBW_MyPrograms\PredSim\opensimAD\buildExpressionGraph\F_Falisse_et_al_2022\F_Falisse_et_al_2022.vcxproj] 
C:\GBW_MyPrograms\PredSim\opensimAD\OpenSimAD-install\sdk\include\OpenSim/Common/Component.h(2124): warning C4068: unknown pragma [C:\GBW_MyPrograms\PredSim\opensimAD\buildExpressionGraph\F_Falisse_et_al_2022\F_Falisse_et_al_2022.vcxproj] 
C:\GBW_MyPrograms\PredSim\opensimAD\OpenSimAD-install\sdk\include\OpenSim/Common/Component.h(2127): warning C4068: unknown pragma [C:\GBW_MyPrograms\PredSim\opensimAD\buildExpressionGraph\F_Falisse_et_al_2022\F_Falisse_et_al_2022.vcxproj] 
c:\gbw_myprograms\predsim\opensimad\opensimad-install\sdk\include\opensim\common\PropertyDblVec.h(145): warning C4477: 'sprintf' : format string '%g' requires an argument of type 'double', but variadic argument 1 has type 'T' [C:\GBW_MyPrograms\PredSim\opensimAD\buildExpressionGraph\F_Falisse_et_al_2022\F_Falisse_et_al_2022.vcxproj] 
          with 
          [ 
              T=osim_double_adouble 
          ] 
  c:\gbw_myprograms\predsim\opensimad\opensimad-install\sdk\include\opensim\common\PropertyDblVec.h(141): note: while compiling class template member function 'std::string OpenSim::PropertyDblVec_<3>::toString(void) const' 
  c:\gbw_myprograms\predsim\opensimad\opensimad-install\sdk\include\opensim\common\Scale.h(57): note: see reference to class template instantiation 'OpenSim::PropertyDblVec_<3>' being compiled 
c:\gbw_myprograms\predsim\opensimad\opensimad-install\sdk\include\opensim\common\PropertyDblVec.h(145): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [C:\GBW_MyPrograms\PredSim\opensimAD\buildExpressionGraph\F_Falisse_et_al_2022\F_Falisse_et_al_2022.vcxproj] 
  C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\stdio.h(1774): note: see declaration of 'sprintf' 
C:\GBW_MyPrograms\PredSim\opensimAD\OpenSimAD-install\sdk\Simbody\include\SimTKcommon/internal/Exception.h(120): warning C4101: 'buf': unreferenced local variable [C:\GBW_MyPrograms\PredSim\opensimAD\buildExpressionGraph\F_Falisse_et_al_2022\F_Falisse_et_al_2022.vcxproj] 
  c:\gbw_myprograms\predsim\opensimad\opensimad-install\sdk\simbody\include\SimTKcommon/internal/StateImpl.h(1190): note: see reference to function template instantiation 'SimTK::Exception::ErrorCheck::ErrorCheck<int,int,const _Elem*,const _Elem*>(const char *,int,const char *,const char *,const char *,int,int,const _Elem *,const _Elem *)' being compiled 
          with 
          [ 
              _Elem=char 
          ] 
SimTKcommon_recorder.lib(SimTKcommon_recorder.dll) : fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'x86' [C:\GBW_MyPrograms\PredSim\opensimAD\buildExpressionGraph\F_Falisse_et_al_2022\F_Falisse_et_al_2022.vcxproj] 
'"C:\GBW_MyPrograms\PredSim\opensimAD\buildExpressionGraph\F_Falisse_et_al_2022\RelWithDebInfo\F_Falisse_et_al_2022.exe"' is not recognized as an internal or external command, 
operable program or batch file. 
Error using copyfile
No matching files named 'C:\GBW_MyPrograms\PredSim\opensimAD\OpenSimAD-install\bin\foo.py' were
found.

Error in buildExpressionGraph (line 105)
    copyfile(path_bin_foo, pathFoo);

Error in generateExternalFunction (line 173)
[fooPath] = buildExpressionGraph(outputFilename, outputDir, compiler, verbose_mode);

Error in osim2dll (line 160)
    generateExternalFunction(osim_path, S.misc.subject_path,...

Error in PreProcessing (line 34)
S = osim2dll(S,osim_path);

Error in run_pred_sim (line 106)
[S,model_info] = PreProcessing(S,osim_path);

Error in main (line 139)
    [savename] = run_pred_sim(S,osim_path);

If you run main.m and encountered an error before seeing "...PreProcessing done. Time elapsed ** s" in the MATLAB command window, we need more detailed logs. Set S.OpenSimADOptions.verbose_mode = true; and run again. This will not solve your problem, but the new log file will give us more information.

Software versions

Additional context Add any other context about the problem here.

VDB-Bram commented 5 months ago

Issue was resolved by adding 'Win64' for the Visual Studio 15 2017 version (as stated in the readme). Furthermore I had to remove all temp files using the function removeAllTempFiles (be sure that the opensimAD folder is in you Matlab path).

This fix works for opensimAD version 012b723de7529c16e4f05add86a10cffcbdf3509