NTNU-IHB / FMI4cpp

FMI 2.0 implementation written in modern C++.
MIT License
92 stars 34 forks source link

Feedback from users #39

Open markaren opened 5 years ago

markaren commented 5 years ago

Hi, I would very much like to hear from you, the person reading this. Why are you interested in this project, have you tried it? What is unclear, what can be improved?

_Note that it is also possible to chat on gitter!_

greenwoodms06 commented 3 years ago

I'll respond to this "issue". I'm interested in trying to get FMUs running in Unreal Engine. I'm just starting (and have minimal C++ experience). So I'm about to try this and/or the FMI++ work....

Curious if you have any insight on if this is a bad idea or if you have any tips to being successful?

markaren commented 3 years ago

I have no experience with Unreal, but if you can import third party libraries using Unreal (which I must assume you can) then it should not be a problem. fmi4cpp is just another C++ library.

greenwoodms06 commented 3 years ago

Super duper. I'm going to give it a go over the next bit. If it works out I'll be sure to give your work a shout out in anything I may produce with it. In any case, thanks for making this available :)

greenwoodms06 commented 3 years ago

Alright. I'm going to risk asking a question and expose my naivety.

Any suggestions for getting this thing to work in Visual Studio (not dealing with unreal yet)? Just trying to do something super simple like your example. c++ noob. Initial efforts had boost and libzip issues, was able to install boost and (I think) libzip but libzip still seems to not be found. The conan approach seems nice but I couldn't get the conan plugin to do anything.

Pointers would be great (pun not intended), though I understand if this is may be more of a "me" problem.

#include <fmi4cpp/fmi4cpp.hpp>

using namespace fmi4cpp;
markaren commented 3 years ago

There is an old vcpkg package available that might be easier to use from a Visual Studio workflow. However, it is unmaintained as I dare not update it as v0.8.0 (master branch) is not backwards compatible with 0.7.0, so an update there would break stuff (I don't know if anyone uses it though). But, I can give no advice on Visual Studio as I've never used it. I use CLion and when building it on the CI server I use raw cmake commands. Perhaps you should try the same? Just take a look at the github workflow file.

greenwoodms06 commented 3 years ago

With a little help of a colleague we were able to get things working on windows/visual studio. Next up is to see if I can throw it in UE4.

markaren commented 3 years ago

You should really consider using Conan to fetch the dependencies. Ideally one should use conan for installing fmi4cpp itself.

git clone https://github.com/NTNU-IHB/fmi4cpp
cd fmi4cpp
conan install . -s build_type=Release --install-folder=build
cmake . -G "Visual Studio 15 2017 Win64" -Bbuild -DFMI4CPP_USING_CONAN=TRUE -DFMI4CPP_BUILD_EXAMPLES=ON
cmake --build build --config Release
markaren commented 3 years ago

Is #include <stdexcept> an issue with VS 2019 compiler?

greenwoodms06 commented 3 years ago

conan might work but this works now. yes the #include <stdexcept> is an issue.

markaren commented 3 years ago

Aight, added the include statement

greenwoodms06 commented 3 years ago

Do you know what about your library forces it to use C++17 instead of c++14? Basically big things or just some simple thing somewhere?

markaren commented 3 years ago

std::optional and std::filesystem comes to mind. Sure it's possible to implement it with boost types & c++14, but I have no interest in doing so. If you really wanted to you could probably make a C++14 compatible fork relatively quickly.

greenwoodms06 commented 3 years ago

alrighty. yeah I'm not asking you to make the changes. just gathering information. thanks

LaurentBauer commented 3 years ago

Hello and thank you for this library

I read a parameric model exported as fmu with OMEdit Now, i'd like to loop over different values for a parameter :

    auto slave = cs_fmu->new_instance();
    for (int i=0; i<10; ++i)
    {
        slave->reset();
        slave->setup_experiment();
        slave->enter_initialization_mode();
        slave->exit_initialization_mode();    // <=  *****HERE*****  crash in the second loop
        ... // change the parameter value in some way 
        slave->write_real(paramValRef, paramVal);  
        while ( (t = slave->get_simulation_time()) <= tmax)        
               slave->step(0.2)
        slave->terminate();
        //... read and cout some results
    }

I'm crashing in the 2nd loop what am i doing wrong ? Nota : it works perfectly if i create a new instance inside the loop. But that doesn't sounds correct to me.

Thank you for any help

markaren commented 3 years ago

what am i doing wrong ?

Either there is an issue with the model or there is an issue with this library. I think you have to test the same logic using a different library to figure out which it is.

LaurentBauer commented 3 years ago

Thank you for the answer. I've tried with another model (the notorious BouncingBall) and encountered the same issue. When importing back my .fmu under OM Editor, I get an error "Operator reinit..." that sounds to be a known "import" bug. See https://trac.openmodelica.org/OpenModelica/ticket/5621 This could be the point if fmi4cpp runs the same engine in background

prudhomm commented 1 year ago

Hi

we use the library to couple FMUs (cosimulation currently) with PDE systems. We replaced fmilib by your library (way cleaner ). it was easy to make the change the maintenance is much easier. We are going to use it more and more in the coming month, we will be able to provide more feedback and possibly contribute.

thanks a lot for your work by the way @markaren !

Andri-e commented 1 year ago

Hi,

Cant seem to get the newest version to work properly, is there a more up to date installation and build guide?

markaren commented 1 year ago

Does it by any chance have to to with conan? They recently bumped the version to 2.x, which is a massive overhaul of the conan system. I wouldn't be surprised if it messed up the conan pipeline here. Assuming this is the issue, you could try switching to 1.x release of conan. In any case I should switch to a vcpkg workflow if I ever find the time.