Note: this document discusses the use of Modelica with the gazebo-fmi Single Body Fluid Dynamics plugin, using OpenModelica. The content should apply also to other Modelica implementation that support the FMI 2.0 standard, but their use was not tested.
There are two ways to generate the FMU file in OpenModelica. Be sure to choose the correct parameters.
Execute OpenModelica and load your model. Eventually load all the needed libraries (i.e. Modelica_Synchronous). Open the menu Tools->Options, tab FMI now choose the correct parameters:
Version:2
Type:Co-Simulation
Platform:Dynamics
Open the menu FMI->Export FMU at this point you have generated the .fmu file.
Execute OpenModelica and load your model. Eventually load all the needed libraries (i.e. Modelica_Synchronous). Open the menu Tools->OpenModelica compiler CLI and type
buildModelFMU(<Your model name without .mo>, "2", "cs", "<default>", {"dynamic"}, true)
At this point you have generated the .fmu file.
In this repo, several examples of Modelica models are used for testing purpouses. We present each of this model as an example of Modelica models used to generate FMU suitable for the single body fluid dynamics forces co-simulation.
Modelica source code: NullFriction.mo
.
This is the simplest example of fluid force: regardless of the value of relativeVelocity
, the fluid dynamics force and moment are always equal to zero. This is equivalent to not load the plugin at all, and is used for consistency tests.
Modelica source code: LinearFriction.mo
.
This is a simple (and not realistic at all) friction, in which the fluid force is linearly related to the relative velocity between the body and the fluid.