I want to know how I can visualise the results of a Modelica simulation in the form of an animation.
Imagine I have a simple simulation as below:
model test
//parameters
parameter Real m_1 = 1;
parameter Real m_2 = 10;
parameter Real K_c = 100000;
//variables
Real x_1;
Real v_1;
Real x_2;
Real v_2;
Real f_1;
Real f_12;
initial equation
x_1 = 0;
v_1 = 0;
x_2 = 0.2;
v_2 = 0;
equation
v_1 = der(x_1);
m_1 * der(v_1) = f_1 - f_12;
v_2 = der(x_2);
m_2 * der(v_2) = f_12;
f_12 = if x_2 >= x_1 then 0 else K_c * (x_1 - x_2);
f_1 = 1;
end test;
(it is actually a very simple elastic collision)
and I have part1.obj and part2.obj (or other possible formats rather than .obj), designed in other CAD software, which I want to import and assign to x_1 and x_2 and then animate. OpenModelica 1.11.0 is already installed on Ubuntu using these instructions.
What I have found so far and the problems I have encountered:
From this page I have learned that Modelica3D should also be installed. However I couldn't find this library using apt or aptitude.
- I found the installation instructions for windows and mac on OpenModelica official website, but no Ubuntu (or other Linux distro) one.
- I have also found this github repo which claims to be a regularly maintained mirror of the original distribution, however the latest commit is for 2 years ago! Not to mention that the original website is dead.
Do I still need to install this library separately or it has already been integrated into the latest stable OpenModelica release? if yes how can I install it? what other libraries/packages might be needed?
Edit: It seems that Modelica3D has been depreciated (same for OMVisualize). Now the ModelicaServices is being used for animation. more information here
This post gives a very simple example of animating using Wolfram SystemModeller. When I open it into the OpenModelica, it does compile and shows the results. I tried exporting the model as FMU and XML and then use animation icon from the top menus to import the model.
but when tried to import the .mat file I got the error:
Scripting Error Could not find the visual XML file /tmp/OpenModelica_user/OMEdit/SimpleCarModel_visual.xml.
Is this example compatible with OpenModelica? and if yes what is the problem and how I can solve it? (you can also download the example from this Github gist)
Edit: This example is compatible with OpenModelica. I was doing it wring. I had to choose the "simulate with Animation" instead of "Simulate". I still can't assign an external CAD object to the simulation and a cylinder is being shown instead.
I also tried to learn using OMShell scripting to run the Modelica3D example from this page. However it seems that the code is wrong because I get many errors running it in my OMShell.
One of the linked websites has mentioned that it is possible to use blender for animated results however the author hadn't succeed to do so. I would appreciate if you could help learn this in simple and clear steps.