Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Visualisation/animation in OpenModelica

Visualisation/animation in OpenModelica

Hi All,

I'm newly experimenting with OpenModelica. I have setup a very basic model (1 d.o.f) in OMEdit which runs ok.

Now I'm trying to view some sort of animation to see if the topography and the movements are correct.

I've tried a few methods without success so far. In OMEdit, the body and joint components that I want to visualise have animation = true. So this should mean that the animation information is included in the results right?

In OMEdit I cannot find anyway to show the animation in the post processing.

I have also tried in OMNotebook, to run the model and call visualise(double_wishbone) but all I get returned is "false"

I know this is something very basic, but could someone point me in the right direction?

Cheers

Tim

PS Here is the model coming from OMEdit

Code:

model double_wishbone

  Modelica.Mechanics.MultiBody.Parts.Body body1(r_CM = {0.2,0,0.3}, m = 5) annotation(Placement(visible = true, transformation(origin = {15.1111,79.5556}, extent = {{12,-12},{-12,12}}, rotation = -270)));
  Modelica.Mechanics.MultiBody.Forces.SpringDamperParallel springdamperparallel1(c = 50000, s_unstretched = 0.5, d = 500) annotation(Placement(visible = true, transformation(origin = {69.7778,52}, extent = {{-12,-12},{12,12}}, rotation = 0)));
  Modelica.Mechanics.MultiBody.Parts.FixedTranslation fixedtranslation2(r = {0.4,0,0}) annotation(Placement(visible = true, transformation(origin = {15.1111,-20.4444}, extent = {{-12,-12},{12,12}}, rotation = 0)));
  Modelica.Mechanics.MultiBody.Parts.FixedTranslation fixedtranslation1(r = {0.4,0,0.3}) annotation(Placement(visible = true, transformation(origin = {20.8889,23.5556}, extent = {{-12,-12},{12,12}}, rotation = 0)));
  Modelica.Mechanics.MultiBody.Joints.Revolute revolute1(n = {0,1,0}) annotation(Placement(visible = true, transformation(origin = {-28,52}, extent = {{-12,-12},{12,12}}, rotation = 0)));
  inner Modelica.Mechanics.MultiBody.World world(label2 = "z", n = {0,0,-1}) annotation(Placement(visible = true, transformation(origin = {-84.0317,4}, extent = {{-12,-12},{12,12}}, rotation = 0)));
equation
  connect(fixedtranslation2.frame_a,world.frame_b) annotation(Line(points = {{3.11111,-20.4444},{-31.5556,-20.4444},{-31.5556,4},{-72.0317,4},{-72.0317,4}}));
  connect(world.frame_b,revolute1.frame_a) annotation(Line(points = {{-72.0317,4},{-51.5556,4},{-51.5556,52},{-40,52}}));
  connect(revolute1.frame_b,fixedtranslation1.frame_a) annotation(Line(points = {{-16,52},{-4,52},{-4,23.5556},{8.88889,23.5556}}));
  connect(revolute1.frame_b,body1.frame_a) annotation(Line(points = {{-16,52},{14.6667,52},{14.6667,67.5556},{15.1111,67.5556}}));
  connect(fixedtranslation1.frame_b,springdamperparallel1.frame_a) annotation(Line(points = {{32.8889,23.5556},{48,23.5556},{48,52},{57.7778,52}}));
  connect(springdamperparallel1.frame_b,fixedtranslation2.frame_b) annotation(Line(points = {{81.7778,52},{90.6667,52},{90.6667,-20.4444},{27.1111,-20.4444}}));
end double_wishbone;

Re: Visualisation/animation in OpenModelica

Hi,

There is some work in progress to make visualization available via
the Modelica 3D library and ModelicaServices, but is not yet integrated
with OMEdit.

You will need the latest nightly-build for this:
https://build.openmodelica.org/omc/buil … ly-builds/
Read OpenModelica user's guide, chapter 11 on python and dependencies. Install those.
Also, you will need to copy C:\OpenModelica1.9.0\lib\omlibrary-modelica3d\libdbus-1.a
to C:\OpenModelica1.9.0\lib\omc\ as we misplaced it in this nightly-build.

Make a file called script.mos containing:

Code:


loadFile("double_wishbone.mo");  getErrorString();
loadModelica3D();
loadString("
partial model Visualization
inner ModelicaServices.Modelica3D.Controller m3d_control;
end Visualization;
model Visualize_DoubleWishBone 
  extends Visualization;
  extends double_wishbone;
end Visualize_DoubleWishBone;
");
simulate(Visualize_DoubleWishBone,stopTime=30); getErrorString();

I assume you're in Windows, if not, let me know.

Now start dbus-server.py from: C:\OpenModelica1.9.0\lib\omlibrary-modelica3d\osg-gtk\dbus-server.py
You can double click on dbus-server.py if you have python installed.

In a Windows command prompt go to where you created script.mos and run:
> C:\OpenModelica1.9.0\bin\omc script.mos
This will run the model and a visualization window will show via dbus-server.py.

Note that all this 3D support is rather preliminary, so not all things are working. For example the "spring" shape is not supported yet.
Hopefully we will fully integrate this into OMEdit for the 1.9.0 release due in 1 month or so.

Cheers,
Adrian Pop/

Re: Visualisation/animation in OpenModelica

Hi Adrian, thanks a lot for that detailed reply.

I will have a go at this this week.

Just a general question, am I doing things the hard way using OMEdit? Do you suggest a better environment for mbs simulation and visualisation? I have seen visualisations in the documentation for OMNotebook so is it worth trying this path as well?

This is only for my own research, so I dont have the budget for Dymola etc.

Thanks again

Regards

Tim Wright

Re: Visualisation/animation in OpenModelica

Hi,

The old visualization from OMNotebook is based on SimpleVisual and OMVisualize which is an OpenModelica library for simple visual animation.
However this is not very detailed and will probably be discontinued when we integrate Modelica 3D library better.

You can do Modelica 3D animation also from OMNotebook via cells and using the commands I gave above.
You will however need to start dbus-server.py outside of OMNotebook or inside it via the system command.

Cheers,
Adrian Pop/

Re: Visualisation/animation in OpenModelica

Hi Adrian,

I've finally found some time to have a look at this. I have seen on the mailing list there has been some further discussions about the 3D visualisation.

In any case, I have downloaded the nightly build from today, and also installed python.

I have follwed what you have done though I'm having problems starting C:\OpenModelica1.9.0\lib\omlibrary-modelica3d\osg-gtk\dbus-server.py. I'm getting the error;

---------------------------
python.exe - Unable To Locate Component
---------------------------
This application has failed to start because MSVCR80.dll was not found. Re-installing the application may fix this problem.
---------------------------
OK   
---------------------------

From looking around I've seen this error is common to a lot of programs, but I've seen nothing specific to python. So I have reinstalled, first 2.7.3 and the 3.3.0 however both are giving me the same thing. I know this isnt a modelica problem, but have you come across this before? could you point me in the right direction?

For information, I'm running Windows XP.

Thanks

Tim

Re: Visualisation/animation in OpenModelica

See here, down below on installing  Visual C++ 2005 SP1 Redistributable Package:
http://stackoverflow.com/questions/3972 … n-c-projec

Cheers,
Adrian Pop/

Re: Visualisation/animation in OpenModelica

Thanks again Adrian,

I did see this error was linked to the Visual C++ redistributable package, so I installed the 2008 version but it didn't solve the problem. I will try again tonight with the 2005 SP1 you suggested.

Tim

Re: Visualisation/animation in OpenModelica

Hi Adrian,

Some progress, but still not there.

After installing the C++ redistributable 2008, 2005 and 2005 SP1 I was still seeing this error. Through some more searching I have seen the I was missing PyGTK. I installed this and was then able to finally start dbus-server.py. I left that window open and ran omc with the script as an input.

omc tries to run the model but fails. I get a very long error message starting with;

Code:


E:\modelica_work_dir\double_wishbone>E:\OpenModelica1.9.0\bin\omc script.mos
true
""
true
true
record SimulationResult
    resultFile = "",
    simulationOptions = "startTime = 0.0, stopTime = 30.0, numberOfIntervals = 5
00, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'Visualize_DoubleWishB
one', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat',
variableFilter = '.*', measureTime = false, cflags = '', simflags = ''",
    messages = "Simulation failed for model: Visualize_DoubleWishBone
Error: Error building simulator. Buildlog: gcc   -falign-functions -msse2 -mfpma
th=sse   -I\"E:/OpenModelica1.9.0//include/omc\" -I.    -c -o Visualize_DoubleWi
shBone.o Visualize_DoubleWishBone.c

after this there are about 100+ lines of errors in Visualise_DoubleWishBone.c

I have also tried to run the double pendulum example given in the users guide in OMShell. Again the model loads ok, but I get this large error when I invoke the simulate command. Again its a long list of errors in Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum.c

So at this point I suspect the problem isn't the model or the commands. Perhaps there is something wrong with my general environment?

Just to give you some more info on exaclty what environmant I'm running;
   Windows XP SP3
   Open Modelica installed in: E:\OpenModelica1.9.0 (nightly build from Build 13859 from today, 11th Nov 2012)
   Model created in OMEdit and saved in working directory E:\modelica_work_dir\double_wishbone
   script.mos which you wrote is in the same directory
   Python 2.7 and PyGTK installed in E:\Python27
   Visual C++ redist 2005, 2008, 2010 installed


So I have run out of ideas, do you have any more advice?

Thanks again

Tim

Re: Visualisation/animation in OpenModelica

Hi,
I don't know if this thread is the way to go, but I've built a 3DOF robot structure (99% similar to the RobotR3) and included it in a model also similar to the one in the the Example library. I'm now trying just to visualize the structure of the robot, not including the drive and control parts of the model. I've tried the steps from the OpenModelica User's Guide, and was able to visualize the DoublePendulum. However, I have tried running both the code in the Guide, and the one you wrote for the script.mos in OMNotebook and they both give me [done] when I've changed the names of the model. I've run the Modelica 3D server beforehand. Haven't really figured out if I'm supposed to extract the simulation from the Visualize_Strukturav2 (my model name) model somehow or is the visualization window supposed to pop up like for the pendulum? When I get rid of the getErrorString(); command, and let the code run without the semicolon after the simulate command with both codes, the error says that the simulation failed:

Code:

true

record SimulationResult
    resultFile = "",
    simulationOptions = "startTime = 0.0, stopTime = 30.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'Visualize_Strukturav2', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''",
    messages = "Simulation failed for model: Visualize_Strukturav2
[<interactive>:7:3-7:22:writable] Error: Base class strukturav2 not found in scope Visualize_Strukturav2
Error: Error occurred while flattening model Visualize_Strukturav2
",
    timeFrontend = 0.0,
    timeBackend = 0.0,
    timeSimCode = 0.0,
    timeTemplates = 0.0,
    timeCompile = 0.0,
    timeSimulation = 0.0,
    timeTotal = 0.0
end SimulationResult;

I located my model into the modelica-3d library, but I'm still not sure how to reference it in the code.
I got interested in OO modeling and I used OpenModelica a bit, but the multibody library and making this animation thing work is kind of complicated, so I thought maybe someone could give me a hand. Thanks in advance for any help or even for just for reading through my message.

Cheers,

Ilma

Re: Visualisation/animation in OpenModelica

Are you able to simulate your model without modelica3D?
Can you post your model?

The error message doesn't seem to be related with visualization.

Adeel.

Re: Visualisation/animation in OpenModelica

Hello,
yes, I can simulate the model. It also works as a part of the robot alltogether. I thought it might be the fact that it's written as a component with hanging flanges, but even without them, it still simulates without modelica3d. The code is the following:

Code:

model strukturav2

  parameter Modelica.SIunits.Acceleration g = 9.81;
  Modelica.SIunits.Angle q[3];
  Modelica.SIunits.AngularVelocity qd[3];
  Modelica.SIunits.AngularAcceleration qdd[3];
  Modelica.SIunits.Torque tau[3];
  inner Modelica.Mechanics.MultiBody.World world annotation(Placement(visible = true, transformation(origin = {-75.2272,-85.0742}, extent = {{-9.01578,-9.01578},{9.01578,9.01578}}, rotation = 0)));
  Modelica.Mechanics.Rotational.Interfaces.Flange_a flange_a annotation(Placement(visible = true, transformation(origin = {-75.4746,52.5041}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {-75.4746,52.5041}, extent = {{-12,-12},{12,12}}, rotation = 0)));
  annotation(Icon(graphics = {Rectangle(rotation = 0, lineColor = {0,0,255}, fillColor = {0,0,255}, pattern = LinePattern.Solid, fillPattern = FillPattern.None, lineThickness = 0.25, extent = {{-58.7952,82.4096},{71.3253,-78.5542}}),Text(rotation = 0, lineColor = {0,0,255}, fillColor = {0,0,255}, pattern = LinePattern.Solid, fillPattern = FillPattern.None, lineThickness = 0.25, extent = {{-35.6627,41.9277},{51.5663,-35.1807}}, textString = "struktura")}), Diagram());
  Modelica.Mechanics.Rotational.Interfaces.Flange_a flange_a1 annotation(Placement(visible = true, transformation(origin = {-74.6542,-2.18767}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {-74.6542,-2.18767}, extent = {{-12,-12},{12,12}}, rotation = 0)));
  Modelica.Mechanics.Rotational.Interfaces.Flange_a flange_a2 annotation(Placement(visible = true, transformation(origin = {-76.268,-54.0188}, extent = {{-12,-12},{12,12}}, rotation = 0), iconTransformation(origin = {-76.268,-54.0188}, extent = {{-12,-12},{12,12}}, rotation = 0)));
  Modelica.Mechanics.MultiBody.Parts.BodyShape bodyshape1(r = {0.2,0.4,0}, m = 3) annotation(Placement(visible = true, transformation(origin = {-2.40964,-83.8554}, extent = {{-12,-12},{12,12}}, rotation = 0)));
  Modelica.Mechanics.MultiBody.Parts.BodyShape bodyshape2(r = {0.2,0.4,0}, m = 3) annotation(Placement(visible = true, transformation(origin = {43.3735,-28.4337}, extent = {{-12,-12},{12,12}}, rotation = 0)));
  Modelica.Mechanics.MultiBody.Parts.BodyShape bodyshape3(r = {0.2,0.4,0}, m = 3) annotation(Placement(visible = true, transformation(origin = {63.1325,24.5783}, extent = {{-12,-12},{12,12}}, rotation = 0)));
  Modelica.Mechanics.MultiBody.Parts.BodyShape bodyshape4(m = 3, r = {0.2,0.4,0}, I_11 = 0.001, I_22 = 0.001, I_33 = 0.001) annotation(Placement(visible = true, transformation(origin = {59.759,80}, extent = {{-12,-12},{12,12}}, rotation = 0)));
  Modelica.Mechanics.MultiBody.Joints.Revolute revolute1(useAxisFlange = true) annotation(Placement(visible = true, transformation(origin = {32.7711,-54.4578}, extent = {{12,-12},{-12,12}}, rotation = -270)));
  Modelica.Mechanics.MultiBody.Joints.Revolute revolute2(useAxisFlange = true) annotation(Placement(visible = true, transformation(origin = {44.8193,-1.92771}, extent = {{12,-12},{-12,12}}, rotation = -270)));
  Modelica.Mechanics.MultiBody.Joints.Revolute revolute3(useAxisFlange = true) annotation(Placement(visible = true, transformation(origin = {37.1084,48.6747}, extent = {{12,-12},{-12,12}}, rotation = -270)));
equation
  connect(revolute3.frame_b,bodyshape4.frame_a) annotation(Line(points = {{37.1084,60.6747},{36.1446,60.6747},{36.1446,80},{47.759,80},{47.759,80}}));
  connect(bodyshape3.frame_b,revolute3.frame_a) annotation(Line(points = {{75.1325,24.5783},{84.8193,24.5783},{84.8193,31.8072},{35.6627,31.8072},{35.6627,38.5542},{37.1084,38.5542},{37.1084,36.6747}}));
  connect(revolute2.frame_b,bodyshape3.frame_a) annotation(Line(points = {{44.8193,10.0723},{41.4458,10.0723},{41.4458,25.0602},{51.1325,25.0602},{51.1325,24.5783}}));
  connect(bodyshape2.frame_b,revolute2.frame_a) annotation(Line(points = {{55.3735,-28.4337},{67.9518,-28.4337},{67.9518,-19.759},{43.8554,-19.759},{43.8554,-13.494},{44.8193,-13.494},{44.8193,-13.9277}}));
  connect(revolute1.frame_b,bodyshape2.frame_a) annotation(Line(points = {{32.7711,-42.4578},{30.8434,-42.4578},{30.8434,-37.5904},{13.494,-37.5904},{13.494,-28.4337},{31.3735,-28.4337},{31.3735,-28.4337}}));
  connect(bodyshape1.frame_b,revolute1.frame_a) annotation(Line(points = {{9.59036,-83.8554},{32.2892,-83.8554},{32.2892,-66.4578},{32.7711,-66.4578}}));
  connect(world.frame_b,bodyshape1.frame_a) annotation(Line(points = {{-66.2114,-85.0742},{-14.4578,-85.0742},{-14.4578,-83.8554},{-14.4096,-83.8554}}));
  connect(revolute3.axis,flange_a) annotation(Line(points = {{25.1084,48.6747},{-74.2169,48.6747},{-74.2169,52.5041},{-75.4746,52.5041}}));
  connect(revolute2.axis,flange_a1) annotation(Line(points = {{32.8193,-1.92771},{-74.2169,-1.92771},{-74.2169,-2.18767},{-74.6542,-2.18767}}));
  connect(revolute1.axis,flange_a2) annotation(Line(points = {{20.7711,-54.4578},{-78.0723,-54.4578},{-78.0723,-54.0188},{-76.268,-54.0188}}));
  q = {revolute1.phi,revolute2.phi,revolute3.phi};
  qd = der(q);
  qdd = der(qd);
  tau = {revolute1.axis.tau,revolute2.axis.tau,revolute3.axis.tau};
end strukturav2;

Re: Visualisation/animation in OpenModelica

It works fine for me.

- I just saved your model into a file "strukturav2.mo".
- Started the dbus-server.py
- Ran the following script.

Code:


loadModel(Modelica, {"3.1"}); getErrorString();
loadModel(ModelicaServices, {"1.0 modelica3d"}); getErrorString();
// get the path to modelica3d patches
m3d_path := getInstallationDirectoryPath() + "/lib/omlibrary-modelica3d/";
// load the changed Modelica.Utilities.Internal
loadFile(m3d_path + "Internal.mo"); getErrorString();
loadFile("strukturav2.mo"); getErrorString();
loadString("
model Visualize_strukturav2
inner ModelicaServices.Modelica3D.Controller m3d_control;
extends strukturav2;
end Visualize_strukturav2;
");
cd("C:/Users/adeas31/AppData/Local/Temp/OpenModelica"); getErrorString();
simulate(Visualize_strukturav2, stopTime=30); getErrorString();

Note that you must save the script file and the strukturav2.mo file at the same level.

Adeel.

Re: Visualisation/animation in OpenModelica

Adeel: Why not use "loadModelica3D()" for the MSL 3.2.1 version (which is much simpler than 3.1)

Re: Visualisation/animation in OpenModelica

No. loadModelica3D() doesn't work.

I think ModelicaServices.Modelica3D.Controller is defined as outer in the default implementation which should be inner. Ask Adrian for details.

Adeel.

Re: Visualisation/animation in OpenModelica

When I run the script in OMNotebook, I get:

Code:

"true

\"\"
true
\"\"
\"C:/OpenModelica1.9.0//lib/omlibrary-modelica3d/\"
true
\"[C:/Users/Ilma/Dropbox/zavrsni/robotic/script1.mos:4:1-4:74:writable] Error: Class getInstallationDirectoryPath not found in scope <global scope> (looking for a function or record).
\"
false
\"\"
true
\"C:/Users/Ilma/Dropbox/zavrsni/robotic\"
\"\"
record SimulationResult
    resultFile = \"\",
    simulationOptions = \"startTime = 0.0, stopTime = 30.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'Visualize_strukturav2', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''\",
    messages = \"Simulation failed for model: Visualize_strukturav2
[<interactive>:4:1-4:20:writable] Error: Base class strukturav2 not found in scope Visualize_strukturav2
Error: Error occurred while flattening model Visualize_strukturav2
\",
    timeFrontend = 0.0,
    timeBackend = 0.0,
    timeSimCode = 0.0,
    timeTemplates = 0.0,
    timeCompile = 0.0,
    timeSimulation = 0.0,
    timeTotal = 0.0
end SimulationResult;
\"\"
"

When I run it in Shell :

Code:

"true

\"\"
true
true
\"C:/Users/Ilma/Dropbox/zavrsni/robotic\"
\"Warning: Requested package ModelicaServices of version 1.0, but this package was already loaded with version 1.0 modelica3d. You might experience problems if these versions are incompatible.
\"
record SimulationResult
    resultFile = \"\",
    simulationOptions = \"startTime = 0.0, stopTime = 30.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'Visualize_strukturav2', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''\",
    messages = \"Simulation execution failed for model: Visualize_strukturav2
\",
    timeFrontend = 3.92805214627592,
    timeBackend = 4.07157468830014,
    timeSimCode = 0.328943884377013,
    timeTemplates = 0.770892440095455,
    timeCompile = 5.99926926902682
end SimulationResult;
\"Warning: No corresponding 'inner' declaration found for component world.x_label.cylinders[1].m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration

I am so sorry if I'm not that familiar with things, I am mostly just starting to work with this.
Thank You so much for your help.

Re: Visualisation/animation in OpenModelica

Which version of OpenModelica are you using?

Try running the script from command line.
Go to your script file location and then run, C:/OpenModelica/bin/omc.exe script.mos (change the path according to your environment).

The reason you are getting this error is because OMNotebook current working directory is %TEMP%. So when you say loadFile("strukturav2.mo") it will fail because the file is located somewhere else. Either use the full path to load file OR change the working directory before calling loadFile.

Assuming your script and model files are loacated at "C:/Users/Ilma/Dropbox/zavrsni/robotic" the following script should work for you,

Code:


loadModel(Modelica, {"3.1"}); getErrorString();
loadModel(ModelicaServices, {"1.0 modelica3d"}); getErrorString();
// get the path to modelica3d patches
m3d_path := getInstallationDirectoryPath() + "/lib/omlibrary-modelica3d/";
// load the changed Modelica.Utilities.Internal
loadFile(m3d_path + "Internal.mo"); getErrorString();
cd("C:/Users/Ilma/Dropbox/zavrsni/robotic"); getErrorString();
loadFile("strukturav2.mo"); getErrorString();
loadString("
model Visualize_strukturav2
inner ModelicaServices.Modelica3D.Controller m3d_control;
extends strukturav2;
end Visualize_strukturav2;
");
simulate(Visualize_strukturav2, stopTime=30); getErrorString();

Adeel.

Re: Visualisation/animation in OpenModelica

I'm using OpenModeica 1.9.0 Beta2 r13495.
I think it gives the same error as before:

Code:

4"true

\"\"
true
\"\"
\"C:/OpenModelica1.9.0//lib/omlibrary-modelica3d/\"
true
\"[C:/Users/Ilma/Dropbox/zavrsni/robotic/script1.mos:4:1-4:74:writable] Error: Class getInstallationDirectoryPath not found in scope <global scope> (looking for a function or record).
\"
\"C:/Users/Ilma/Dropbox/zavrsni/robotic\"
\"\"
true
\"\"
true
record SimulationResult
    resultFile = \"\",
    simulationOptions = \"startTime = 0.0, stopTime = 30.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'Visualize_strukturav2', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''\",
    messages = \"Simulation execution failed for model: Visualize_strukturav2
\",
    timeFrontend = 3.62144810352734,
    timeBackend = 6.58144509849884,
    timeSimCode = 0.373417074555496,
    timeTemplates = 0.548226807399431,
    timeCompile = 8.27939950334925
end SimulationResult;
\"Warning: No corresponding 'inner' declaration found for component world.x_label.cylinders[1].m3d_control declared as 'outer '.
  The existing 'inner' components are:
    There are no 'inner' components defined in the model in any of the parent scopes of 'outer' component's scope: Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
  Check if you have not misspelled the 'outer' component name.
  Please declare an 'inner' component with the same name in the top scope.
  Continuing flattening by only considering the 'outer' component declaration.

the segment after "Warning:..repeats itself for different components a lot.
I'm getting the feeling this won't be working, I feel really bad for taking your time..
Thank you, but feel free to ignore me if you have other things to do current/big_smile

Re: Visualisation/animation in OpenModelica

The interesting error message is,

Code:

\"[C:/Users/Ilma/Dropbox/zavrsni/robotic/script1.mos:4:1-4:74:writable] Error: Class getInstallationDirectoryPath not found in scope <global scope> (looking for a function or record).

I am not sure why getInstallationDirectoryPath() is failing. I recommend installing a new OpenModelica nightly build since the one you are using is almost 4000 revisions old version.
https://build.openmodelica.org/omc/buil … ly-builds/

Things are getting closer don't give up current/smile

Adeel.

Re: Visualisation/animation in OpenModelica

Yaaay, it works now! Thank you soo much current/smile I'll try to visualize the entire robot model now. Do I have to add code to the script? I don't even know it it can be animated since it contains stuff from the rest of the Mechannical library, Blocks and Electrical. Thank you so much, again! (I just love that hype phase I go through when something starts working current/big_smile)

Re: Visualisation/animation in OpenModelica

Now, I can get none of the models I used to run normally in Connection Editor to simulate. First I got some errors but couldn't even see them cause the Editor kept crashing. Then I saw it said something about +d=initialization. I tried changing some of the initialization values for the inertia components, then it said it was an overdetermined system. I can't figure out why it doesn't simulate since the animation still works. This the warning after running the strukturav2 animation in Shell.

Code:

 "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.

Warning: There are iteration variables with default zero start attribute. Use +d=initialization for more information.

I also had problems with the Editor after updating to Beta4, with the Media library, so I uninstalled both versions and installed the Beta4 again. Now, there is no problem with libraries, but still the Editor crashes even after I run the DoublePendulum example, and shows these 2 errors I think, but can't really be sure since it goes down mid-simulation.
I can't even start to figure out where to fix what. I'd think it's my model, but it also happens with integrated examples and all of my models simulated perfectly in the previous version.

Re: Visualisation/animation in OpenModelica

You should enable the initialization flag via Tools->Options->Simulation and then in the OMC Flags text box enter,

Code:

+d=initialization

It will remove the initialization warning message but it will output other initialization warnings that you should fix. The rules for initialization are more up to the specification now which were not even checked in the previous versions. Post the warnings. I will ask Lennart to help you with initialization issues.

Adeel.

Re: Visualisation/animation in OpenModelica

I already did that, but as I said, the Editor crashes and the error message isn't visible really. All see is something along the lines of assumed fixed start for the angle in revolutes in the model. (when i try running the strukturav2 model).

Re: Visualisation/animation in OpenModelica

OK. Thats my mistake. Thanks for finding this error. I will try to fix it ASAP.
You can use the one night earlier build https://build.openmodelica.org/omc/buil … -17148.exe until I fix the issue.

Adeel.

Re: Visualisation/animation in OpenModelica

Thanks for the help, and I'm glad I could contribute. The previous build works like a charm, I don't have to change anything in the models for now.

Re: Visualisation/animation in OpenModelica

Hello,

I'm new to modelling. I'm trying to get the visualization working on Debian.
The model is Pendulum.mo included in Modelica3D package.

Actions taken so far and the environment details follow.
The best option would be if someone would kindly present his opinion on how to run all this on this OS, because what you'll see below is a mere magical trick to me and should not, perhaps, be modified at all, but instead built from scratch.


So, what I'm doing:

In Terminal run:

Code:

python '/usr/lib/omlibrary-modelica3d/osg-gtk/dbus-server.py'

Open OMShell and run the following script, analogous to what seems to have solved one of the previous authors' problem:

Code:


loadModelica3D();

loadModel(Modelica, {"3.2.1"}); getErrorString();
loadModel(ModelicaServices, {"3.2.1 modelica3d"}); getErrorString();

m3d_path := getInstallationDirectoryPath() + "/lib/omlibrary-modelica3d/";

loadFile(m3d_path + "Internal.mo"); getErrorString();
loadFile(m3d_path + "Pendulum.mo"); getErrorString();

loadString("
model Visualize_Pendulum
inner ModelicaServices.Modelica3D.Controller m3d_control;
extends Pendulum;
end Visualize_Pendulum;
");

simulate(Visualize_Pendulum, stopTime=30); getErrorString();

The output (from the very beginning) looks like this. So, it fails to compile, doesn't it?

Code:


OMShell 1.1 Copyright Open Source Modelica Consortium (OSMC) 2002-2013
Distributed under OMSC-PL and GPL, see www.openmodelica.org

Connected to OpenModelica 1.9.0 RC1+dev (r17557)
To get help on using OMShell and OpenModelica, type "help()" and press enter.

>> runScript("/home/vf/modelica/s1.mos")
"true
true
\"Warning: Requested package ModelicaServices of version 3.2.1, but this package was already loaded with version 3.2.1 modelica3d. You might experience problems if these versions are incompatible.
\"
true
\"\"
\"/usr/lib/omlibrary-modelica3d/\"
true
\"\"
true
\"\"
true
record SimulationResult
    resultFile = \"\",
    simulationOptions = \"startTime = 0.0, stopTime = 30.0, numberOfIntervals = 500, tolerance = 0.000001, method = 'dassl', fileNamePrefix = 'Visualize_Pendulum', options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''\",
    messages = \"Simulation failed for model: Visualize_Pendulum
[<interactive>:4:1-4:17:writable] Error: Base class Pendulum not found in scope Visualize_Pendulum.
[<interactive>:3:1-3:57:writable] Error: Class ModelicaServices.Modelica3D.Controller not found in scope Visualize_Pendulum.
Error: Error occurred while flattening model Visualize_Pendulum
\",
    timeFrontend = 0.0,
    timeBackend = 0.0,
    timeSimCode = 0.0,
    timeTemplates = 0.0,
    timeCompile = 0.0,
    timeSimulation = 0.0,
    timeTotal = 0.0
end SimulationResult;
\"\"
"

>>

I would greatly appreciate any advice and try to communicate back as soon as possible.

------------------------------------------------
Debian 7.1.0

Packages (versions) installed:

openmodelica (17557-1)
omlib-modelica-3.2.1 (7053-om1-1)
omlib-modelicaservices-3.2.1 (6931-om1-1)
omlib-modelicaservices-3.2.1-modelica3d (6931-om-m3-d23-om3d5-1)
libmodelica3d (17557-1)
omlib-modelicareference (6944-1)
drmodelica (17557-1)
omlib-complex-3.2.1 (6931-om1-1)
omedit (17557-1)
omoptim (17557-1)

------
Best regards,
Kirill

Re: Visualisation/animation in OpenModelica

You should not load the internal models! (They are only for MSL 3.1) No need to load the packages again either.

Code:

loadModelica3D();getErrorString();

loadString("model DoublePendulum
  extends Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum;
  inner ModelicaServices.Modelica3D.Controller m3d_control;
end DoublePendulum;");getErrorString();
simulate(DoublePendulum);

That's all.

Re: Visualisation/animation in OpenModelica

Thank you for the fast reply.

Running this script gives warnings about start values and an error: "/usr/bin/ld: cannot find -ldbus-1".

With the "+d=initialization" option (lists of variables not shown):

Code:


record SimulationResult
    resultFile = "",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 0.000001, method = 'dassl', fileNamePrefix = 'DoublePendulum', options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''",
    messages = "Simulation failed for model: DoublePendulum
Warning: Assuming fixed start value for the following 285 variables:
========= <Here comes a list of roughly 300 variables> ============


Warning: Iteration variables with default zero start attribute in equation system:
========= <Here comes a list of roughly 10 variables> ============

Error: Error building simulator. Build log: gcc   -falign-functions -march=native -mfpmath=sse   -I\"/usr/include/omc\" -I.   -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME  -c -o DoublePendulum.o DoublePendulum.c
gcc   -falign-functions -march=native -mfpmath=sse   -I\"/usr/include/omc\" -I.   -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME  -c -o DoublePendulum_records.o DoublePendulum_records.c
g++ -I. -o DoublePendulum DoublePendulum.o DoublePendulum_records.o -I\"/usr/include/omc\" -I.   -DOPENMODELICA_XML_FROM_FILE_AT_RUNTIME  -lmodcount -lModelicaExternalC -lmodbus -ldbus-1    -falign-functions -march=native -mfpmath=sse   -L\"/usr/lib/omc\" -L\"/usr/lib\" -Wl,-rpath,\"/usr/lib/omc\" -Wl,-rpath,\"/usr/lib\" -lSimulationRuntimeC   -ldl -linteractive  -lexpat    -lrt -lgc -lexpat -fopenmp -lsundials_kinsol -lsundials_nvecserial -llapack  -lpthread -Wl,-Bstatic -lf2c -Wl,-Bdynamic -llis
/usr/bin/ld: cannot find -ldbus-1
collect2: error: ld returned 1 exit status
make: *** [omc_main_target] Error 1

",
    timeFrontend = 0.0,
    timeBackend = 0.0,
    timeSimCode = 0.0,
    timeTemplates = 0.0,
    timeCompile = 0.0,
    timeSimulation = 0.0,
    timeTotal = 0.0
end SimulationResult;

So, it yet can't find the mysterious -ldbus-1 (although dbus is installed).

Re: Visualisation/animation in OpenModelica

apt-get install libdbus-1-dev maybe? Tell me if that helps and I will add it to the dependencies

Re: Visualisation/animation in OpenModelica

This did the trick, thank you.

By the way, dbus, libdbus-1-3, libdbus-glib-1-2 (included in distribution) and libdbus-c++-1-0 (added later) did not suffice.

----
update:
In case this is not a common behavior: closing the viewer kills the dbus_server, so to visualize the next simulation one must re-run dbus_server.py.

----
update 2:

Simulating DoublePendulum, then running this:

Code:


loadString("model Pendulum
  extends Modelica.Mechanics.MultiBody.Examples.Elementary.Pendulum;
  inner ModelicaServices.Modelica3D.Controller m3d_control;
end Pendulum;");getErrorString();
simulate(Pendulum);

and then simulating DoublePendulum again works in the following manner:

first two simulations are okay, but the last one has 3D models messed up, although it shows correct motion (as I can see from what remains of the visual shapes).
dbus_server at the time shows multiple "inconsistent naming, could not find ....".

Is the user supposed to relaunch dbus_server between simulations?

There are 0 guests and 0 other users also viewing this topic
You are here: