Matlab keeps crashing while running script using MATLAB/OpenSim interface

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Jennifer Dawkins
Posts: 1
Joined: Tue Jun 26, 2018 8:38 am

Matlab keeps crashing while running script using MATLAB/OpenSim interface

Post by Jennifer Dawkins » Wed Aug 15, 2018 7:33 am

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

Tags:

User avatar
z imn
Posts: 35
Joined: Sun Sep 17, 2017 7:11 am

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

Post by z imn » Wed Aug 15, 2018 7:36 am

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...

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

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

Post by jimmy d » Wed Aug 15, 2018 11:27 am

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

User avatar
z imn
Posts: 35
Joined: Sun Sep 17, 2017 7:11 am

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

Post by z imn » Wed Aug 15, 2018 1:15 pm

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

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

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

Post by jimmy d » Wed Aug 15, 2018 4:57 pm

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);


User avatar
z imn
Posts: 35
Joined: Sun Sep 17, 2017 7:11 am

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

Post by z imn » Fri Aug 17, 2018 9:38 pm

thanks for your attention
the code ran correctly.
king regards

POST REPLY