opensim-org / opensim-core

SimTK OpenSim C++ libraries and command-line applications, and Java/Python wrapping.
https://opensim.stanford.edu
Apache License 2.0
802 stars 324 forks source link

Instantiate Models in Matlab causes vtp warning #2375

Open jimmyDunne opened 6 years ago

jimmyDunne commented 6 years ago

In Matlab, when creating a new model and assigning display geometry, the OpenSim API must not know where the Geometry folder is and prints warnings to the console. The easiest way to see this is by running OpenSimCreateCreateTugOfWarModel.m

image

The Model Geometry is viewable when opened in the GUI, however this should be considered an isuue since;

  1. If I try to view a simulation with this model in Matlab, the display geometry doesn't show.
  2. The warning gets printed to console at every addComponent (addBody(), addForce(), addController()) and can be (is) distracting.

I tried adding the Geometry folder path to Matlab path and my terminal path to no avail ☹️

chrisdembia commented 6 years ago

We should emit those warnings only once, and we might be able to read the GUI's Geometry Path preference using Windows' registry.

For now, you should be able to set the OPENSIM_HOME environment variable to a directory that contains a Geometry folder (that is not the geometry folder itself, but one level up).

aymanhab commented 6 years ago

Alternatively you can do what the GUI does which is call ModelVisualizer.addDirToGeometrySearchPaths(path)

aymanhab commented 6 years ago

@jimmyDunne For first example e.g. tug-of-war, we probably don't want to use vtp files and have users deal with this issue altogether. The model has built-in shapes mostly. It would be better to use Bricks and Spheres rather than vtp files.

jimmyDunne commented 6 years ago

Sure— but doesn't change that this needs will need to be altered. Users are already (rightly) complaining (forum)

clnsmith commented 5 years ago

I'm also running into this in C++ code as well. It is annoying since it throws the warnings everytime you call initSystem.

Another option is to add a Property to the Model (and thus .osim file) that is GeometrySearchPath. Currently when I am developing a new model, I often have different model versions in different folders. Right now I have to duplicate the "Geometry" folder into each of these model version folders. The other option is to use full system paths to the geometry files in the model file, but this is annoying if you are using multiple computers/sharing models. I guess you would still need to change the GeometrySearchPath, so maybe its not that great of an idea, but atleast that is only one line.

chrisdembia commented 5 years ago

Good idea. We could also consider allowing some sort of per-model environment variable or config file in the user's home directory.

We should also emit the warning only once.

Does using model.updVisualizer().addDirToGeometrySearchPaths() help for now?

aymanhab commented 5 years ago

Thanks for reporting @clnsmith I think the right fix is to have a clear "Stage" where some checks are made at this Stage e.g. deserialization but not all the time (e.g. finalizeXXXXX). The essence of the problem as I see it is that we have a big :hammer: and we use it all the time because there's no granularity in the tricky initialization sequence. My 2 cents.

jimmyDunne commented 5 years ago

@aseth1 suggested adding a method that disables reading in geometry.

Visualizing the geometry could be set off by default and the Visualize() could set the model geometry to true

aymanhab commented 5 years ago

My investigation so far:

jimmyDunne commented 5 years ago

I think everyone is in agreement that we should find a way to stop these warnings, so whatever the best system is for dealing with that would be good. If it is to add properties, then we should explore that.