Page 1 of 1

Matlab keeps crashing while running script using MATLAB/OpenSim interface

Posted: Wed Aug 15, 2018 7:33 am
by jendawk
I am running a script that uses primarily the scaling tool and then runs static optimization and joint reaction analysis. MATLAB crashes every time I run it, though it does seem to finish all the functions (it just crashes right after, and thus doesn't get to subsequent loops). I have been working with MATLAB support, and they said that it was from the OpenSim interface and the crash log indicated that it was a result of not having the file 'osimSimulation.dll in OpenSim 3.3\bin\. However, I have checked and I do have that file.

Has anyone dealt with similar issues?

Thanks!
Jennifer

Re: Matlab keeps crashing while running script using MATLAB/OpenSim interface

Posted: Wed Aug 15, 2018 7:36 am
by zohreh
hello
i have the same issue....
but i could not solve it
as far as i know ...opensim has problem in loops ....
not only for complete runs but also for a simple loop it crashes...

Re: Matlab keeps crashing while running script using MATLAB/OpenSim interface

Posted: Wed Aug 15, 2018 11:27 am
by jimmy
Hi, Jennifer-

This type of error occurs when there is an exception happening on the C++ side and it is not caught by the java (Matlab) wrapping. These types of errors can be hard to diagnose because often it has to do with internal memory. For example, functions that make multiple copies, references, and edits to a single Model object could cause a segfault if the program isn't sure where to make the changes in memory. It is almost impossible to diagnose without seeing the code itself, so if you can post it here we may be able to give you some feedback.

-J

Re: Matlab keeps crashing while running script using MATLAB/OpenSim interface

Posted: Wed Aug 15, 2018 1:15 pm
by zohreh
hello
my last post in address (viewtopicPhpbb.php?f=91&t=9396&p=25818&start=0&view=) has the same issue...
that is a short code and i just ran it for 2 loops . but matlab was crashed.
here i repeated it
import org.opensim.modeling.*

Code: Select all

for i=1:2
osimModel(i)=Model('E:\phd_mechanic\API\API_modeling\fix\scaled_model_without_markers.osim');
markers(i)=MarkerSet('E:\phd_mechanic\API\API_modeling\fix\markers.xml');
LTTT(i)=Marker();
LTTT(i).setName('LTTT');
LTTT(i).setBodyName('tibia_l');
LTTT(i).setFixed(true);
LTTT(i).print(['LTTT_' num2str(i) '.xml']);
markers(i).adoptAndAppend(LTTT(i));
markers(i).print(['markers_' num2str(i) '.xml']);
osimModel(i).updateMarkerSet(markers(i));

end

Re: Matlab keeps crashing while running script using MATLAB/OpenSim interface

Posted: Wed Aug 15, 2018 4:57 pm
by jimmy
I am not sure why you are trying to assign a model object to an index in a Matlab matrix. There has also been previously noted issues with .adoptAndApend, try and use cloneAndAppend.

A working version is below.

Code: Select all

import org.opensim.modeling.*
% Instantiate a Model object
osimModel = Model('gait2392_simbody.osim');
% Instantiate a MarkerSet object
markers   = MarkerSet('gait2392_Scale_MarkerSet.xml');

% Define a list of maker labels
markerlabels = [{'marker_1'} {'marker_2'}];

% Add each of the markers in markerlabels to the markerset
for i = 1 : 2
    % Instantiate a marker object
    LTTT = Marker();
    % Set the Marker Name
    LTTT.setName(markerlabels{i});
    % Set the marker the body is attached to
    LTTT.setBodyName('tibia_l');
    % Set is fixed
    LTTT.setFixed(true);
    % Set the marker location in the body frame
    LTTT.setOffset( Vec3(0.5,0.5,0.5) );
    % Add the marker to the markerset
    markers.cloneAndAppend(LTTT);
end
% Print the marker set to file
markers.print(['markers_' num2str(i) '.xml']);
% Update the markerset of the model with the new markerset
osimModel.updateMarkerSet(markers);


Re: Matlab keeps crashing while running script using MATLAB/OpenSim interface

Posted: Fri Aug 17, 2018 9:38 pm
by zohreh
thanks for your attention
the code ran correctly.
king regards