Matlab Crashes on initSystem() / Frame not connected error && motion can't be displayed
Posted: Thu Dec 05, 2019 5:28 am
Hi everybody,
since two month I am working with openSim 4.0 for my master thesis. I am using the interface with Matlab since I will have several simulation runs once my code is finished.
I use a model that - to my knowlegde- has been developed with OpenSim 3.2 and has been adapted to OpenSim4.0 before it was given to me.
In my code, I add bodies, markers and geoemtries, then I scale this "generic model" to three different sizes and do IK runs. All the steps are coded in matlab.
I have two major issues with thrown errors that I don't understand.
1) Matlab crashes / Frame not connected error
When I started working, everything worked fine, but now Matlab crashes really often, sometimes without any warning. I could track it down to the model.initSystem() call. However, matlab does not crash every time nor does it crash always on the first time I call initSystem() (e.g. it is called for each scale separately). For me it seems to be quite randomly, especially as it is possible that my code runs through sometimes without any issue.
Interestingly, sometimes instead of matlab crashing a java exception is thrown in the matlab console when initSystem() is called. Also, this actuates the same way that it doesn't happen on each run and the initSystem() where it is thrown can be at different places / own functions in my code.
[I additionally realized that sometimes model.print(filename) might be the code line where matlab crashes, if this helps. Furthermore, often my CPU-usage is very high when matlab crashes. When I get the error instead of crashing, the CPU-usage is lower.]
This is the java exception thrown:
Java exception occurred:
java.io.IOException: Failed to connect Socket 'frame' of type Frame (details: Component 'tibia_r_geom_1'
could not find '..' of type Frame. Make sure a component exists at this path and that it is of the correct
type.
Thrown at component.h:764 in getComponent().).
In Object 'tibia_r_geom_1' of type Mesh.
Thrown at component.cpp:312 in finalizeConnections().
at org.opensim.modeling.opensimSimulationJNI.Model_initSystem(Native Method)
at org.opensim.modeling.Model.initSystem(Model.java:848)
The component named in the java exception changes in each case, it might be also for example: Component 'patella_l_geom_1' or Component 'talus_r_geom_1', both with a socket_frame "..". (Those are bodies that are in the original model given to me and are not created by me within the matlab code.)
What makes it really difficult for me to understand the issue, is that this problem is not happening regularly. Somethime the code works, sometimes it crashes, sometimes I get the error, everytime at different positions in my code. I would say that 4 out of 5 runs, my code runs through.
Well, and then there is the case where matlab shows the crash-window ("Matlab has encountered an internal problem and needs to close") but the code keeps running and I can just ignore the crash-window and continue working, coding, run code withing matlab without any issue.
In contrast to that, there is one case, where Matlab ALWAYS crashes when using initSystem(). If I want to visualize any model with the matlab visualizer (also the examples you deliver with the openSim 4.0 distribution), I need to call "model.setUseVisualizer(true)" and afterwards calling the next initSystem() will cause Matlab to crash. With model.setUseVisualizer(false) this won't happen.
Interestingly, if I let try anybody else at my university department to run e.g. TugOfWar_CompleteRunVisualize.m on his user on the same computer, the code executes and shows the visualisation window. On my user, matlab crashes on initSystem() executing the same code example. Therefor it seems to me that the issue might also be user-related?
As you can see, this doesn't seem to be a consistent error. I really read a lot of error descriptions in the forum / github etc but I couldn't fix any of these issues.
I would be very glad if you could help me.
2) motion file (result from IK tool) throw error
My code creates (using the IK tool) two different motion files (snychrone and asynchrone cranking) which are stored as mot-files in my workspace.
The Matlab console tells me that the IK tool completed.
When I open afterwards my scaled model in the GUI and load the motion into it, one of both files (asynchrone) won't work.
There are two different reactions by the GUI:
The first option is, when I make the motion current in the navigation tree (it is marked as bold), the motion menu on the top of the GUI with the "movie options" stays greyed out and I can see on the bottom of the GUI a small red sign that an error ( "A java.lang.IndexOutOfBoundsException exception has occurred.") has been thrown when the motion got loaded into the GUI.
The second option is that i can actually start displaying the motion but after the first time frames the same error is shown in an opening error window: "A java.lang.IndexOutOfBoundsException exception has occurred.". I attached the message.log file that OpenSim has automatically saved.
I would really appreciate if you have any hint that might help.
Currently I am out of ideas.
Thank you very much.
Best regards
Ruth Meissner
I am working with OpenSim4.0
path variable is correctly set
Windows 7
since two month I am working with openSim 4.0 for my master thesis. I am using the interface with Matlab since I will have several simulation runs once my code is finished.
I use a model that - to my knowlegde- has been developed with OpenSim 3.2 and has been adapted to OpenSim4.0 before it was given to me.
In my code, I add bodies, markers and geoemtries, then I scale this "generic model" to three different sizes and do IK runs. All the steps are coded in matlab.
I have two major issues with thrown errors that I don't understand.
1) Matlab crashes / Frame not connected error
When I started working, everything worked fine, but now Matlab crashes really often, sometimes without any warning. I could track it down to the model.initSystem() call. However, matlab does not crash every time nor does it crash always on the first time I call initSystem() (e.g. it is called for each scale separately). For me it seems to be quite randomly, especially as it is possible that my code runs through sometimes without any issue.
Interestingly, sometimes instead of matlab crashing a java exception is thrown in the matlab console when initSystem() is called. Also, this actuates the same way that it doesn't happen on each run and the initSystem() where it is thrown can be at different places / own functions in my code.
[I additionally realized that sometimes model.print(filename) might be the code line where matlab crashes, if this helps. Furthermore, often my CPU-usage is very high when matlab crashes. When I get the error instead of crashing, the CPU-usage is lower.]
This is the java exception thrown:
Java exception occurred:
java.io.IOException: Failed to connect Socket 'frame' of type Frame (details: Component 'tibia_r_geom_1'
could not find '..' of type Frame. Make sure a component exists at this path and that it is of the correct
type.
Thrown at component.h:764 in getComponent().).
In Object 'tibia_r_geom_1' of type Mesh.
Thrown at component.cpp:312 in finalizeConnections().
at org.opensim.modeling.opensimSimulationJNI.Model_initSystem(Native Method)
at org.opensim.modeling.Model.initSystem(Model.java:848)
The component named in the java exception changes in each case, it might be also for example: Component 'patella_l_geom_1' or Component 'talus_r_geom_1', both with a socket_frame "..". (Those are bodies that are in the original model given to me and are not created by me within the matlab code.)
What makes it really difficult for me to understand the issue, is that this problem is not happening regularly. Somethime the code works, sometimes it crashes, sometimes I get the error, everytime at different positions in my code. I would say that 4 out of 5 runs, my code runs through.
Well, and then there is the case where matlab shows the crash-window ("Matlab has encountered an internal problem and needs to close") but the code keeps running and I can just ignore the crash-window and continue working, coding, run code withing matlab without any issue.
In contrast to that, there is one case, where Matlab ALWAYS crashes when using initSystem(). If I want to visualize any model with the matlab visualizer (also the examples you deliver with the openSim 4.0 distribution), I need to call "model.setUseVisualizer(true)" and afterwards calling the next initSystem() will cause Matlab to crash. With model.setUseVisualizer(false) this won't happen.
Interestingly, if I let try anybody else at my university department to run e.g. TugOfWar_CompleteRunVisualize.m on his user on the same computer, the code executes and shows the visualisation window. On my user, matlab crashes on initSystem() executing the same code example. Therefor it seems to me that the issue might also be user-related?
As you can see, this doesn't seem to be a consistent error. I really read a lot of error descriptions in the forum / github etc but I couldn't fix any of these issues.
I would be very glad if you could help me.
2) motion file (result from IK tool) throw error
My code creates (using the IK tool) two different motion files (snychrone and asynchrone cranking) which are stored as mot-files in my workspace.
The Matlab console tells me that the IK tool completed.
When I open afterwards my scaled model in the GUI and load the motion into it, one of both files (asynchrone) won't work.
There are two different reactions by the GUI:
The first option is, when I make the motion current in the navigation tree (it is marked as bold), the motion menu on the top of the GUI with the "movie options" stays greyed out and I can see on the bottom of the GUI a small red sign that an error ( "A java.lang.IndexOutOfBoundsException exception has occurred.") has been thrown when the motion got loaded into the GUI.
The second option is that i can actually start displaying the motion but after the first time frames the same error is shown in an opening error window: "A java.lang.IndexOutOfBoundsException exception has occurred.". I attached the message.log file that OpenSim has automatically saved.
I would really appreciate if you have any hint that might help.
Currently I am out of ideas.
Thank you very much.
Best regards
Ruth Meissner
I am working with OpenSim4.0
path variable is correctly set
Windows 7