Matlab crashes when running a simulation

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Pasha van Bijlert
Posts: 229
Joined: Sun May 10, 2020 3:15 am

Matlab crashes when running a simulation

Post by Pasha van Bijlert » Mon Jul 06, 2020 2:29 pm

Hello! I'm trying to get the Matlab scripting environment up and running in preparation for tomorrow's webinar. I followed all the steps (including adding the path environment variable and running as administrator). Matlab displays the correct version number (4.1) when I run org.opensim.modeling.opensimCommon.GetVersion() , and I am able to successfully run simulations using the GUI.

However, when I run a simulation (using one of the provided example scripts), Matlab crashes (due to a Java error, apparently). I have subsequently updated my version of Java to the most recent one, which unfortunately did not resolve my issue, and the crash logs aren't making me any wiser. I was hoping that someone here might be able to help me? I have added the crash logs which also contain detailed specs of my laptop. I'm running Windows 10 with an I7 processor and 24 GB of ram.
Attachments
hs_error_pid10628.log
Java error log
(45.29 KiB) Downloaded 50 times
matlab_crash_dump.10628-1.txt
Matlab error log
(4.84 KiB) Downloaded 44 times

Tags:

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Matlab crashes when running a simulation

Post by Christopher Dembia » Mon Jul 06, 2020 2:47 pm

Hey Pasha,

This is likely a known issue associated with the API Visualizer. If you comment out the line `model.setUseVisualizer(true)`, does the crash go away?

User avatar
Pasha van Bijlert
Posts: 229
Joined: Sun May 10, 2020 3:15 am

Re: Matlab crashes when running a simulation

Post by Pasha van Bijlert » Mon Jul 06, 2020 3:17 pm

Hi Christopher,

Thanks, matlab didn't crash this time. Does this mean that it is currently impossible to run visualizations from a matlab script, or are there some steps I could take to fix this?

By the way, your (and your co-author's) preprint on Moco has inspired me to use OpenSim for my next project. Initially, I was planning on trying to implement direct collocation myself, but your webinar + preprint (and a presentation by Friedl de Groote at our faculty in Amsterdam) convinced me to try building the model in OpenSim instead. I'm very excited to try it out!
Last edited by Pasha van Bijlert on Tue Jul 07, 2020 2:42 am, edited 1 time in total.

User avatar
Christopher Dembia
Posts: 506
Joined: Fri Oct 12, 2012 4:09 pm

Re: Matlab crashes when running a simulation

Post by Christopher Dembia » Mon Jul 06, 2020 3:48 pm

Pasha:

This is a high-priority bug for us, but we've been unable to reproduce it ourselves, which limits our ability to fix the bug. We do not know of a fix yet. You can use the OpenSim GUI for visualization.

Regarding Moco, that's great for me, Nick, and the rest of the OpenSim team to hear! Please let us know if you have questions.

Friedl is a great researcher; I'm glad you got the chance to meet her.

User avatar
Pasha van Bijlert
Posts: 229
Joined: Sun May 10, 2020 3:15 am

Re: Matlab crashes when running a simulation

Post by Pasha van Bijlert » Tue Jul 07, 2020 2:59 am

Ah, I misspelled her name, corrected it now.

Let me know if you'd like some more information on my system/installation, since you're having trouble reproducing the bug.

Regarding Moco: thank you! Right now, the first step is getting acquainted with building OpenSim models using Matlab. The goal is to get to a point where the model is parametric, so for instance inertial parameters, muscle moment arms, etc, can all be changed from the script. Any resources on this would be very helpful!

User avatar
Pasha van Bijlert
Posts: 229
Joined: Sun May 10, 2020 3:15 am

Re: Matlab crashes when running a simulation

Post by Pasha van Bijlert » Tue Jul 14, 2020 3:23 am

So to circumvent the visualizer not working, I was trying to build a statestrajectoryreporter into the model that you had provided for the Matlab scripting webinar (with the help of one of your colleagues in zoom). I'm hoping to simply access all of the states of the simulation (as a timeseries) so I can either export them as a .sto, or just post process in matlab (i.e. make some plots to see what's happening). We tried the following implementation of statestrajectoryreporter, but it doesn't seem to work (i.e. the table allStateVars is empty). Is there an example script available for statestrajectory reporter? I'd seen the example script where you have to individually pass on each variable you would like to be reported, but I'm looking to get all of the data in one reporter and decide later on what I choose to plot. Any help would be appreciated!

clear;
import org.opensim.modeling.*;

% Build a model.
model = Model();
body = Body('body', 1.0, Vec3(0), Inertia(0));
body.attachGeometry(Sphere(0.1));
model.addBody(body);

joint = SliderJoint('joint', model.getGround(), body);
coord = joint.updCoordinate();
coord.setName('translation');
model.addJoint(joint);

actuator = CoordinateActuator('translation');
actuator.setName('actuator');
model.addForce(actuator);

controller = PrescribedController();
%methodsview(controller);
controller.addActuator(actuator);
controller.prescribeControlForActuator('actuator', Sine());
model.addController(controller);


% add a reporter for the timeseries
reporter=StatesTrajectoryReporter();
reporter.setName('states_reporter');
reporter.set_report_time_interval(0);

model.addComponent(reporter)
disp(reporter.dump())


model.finalizeConnections();
model.print('pointmass.osim');

% Simulate a model.
%model.setUseVisualizer(true);
initState = model.initSystem();
disp(initState.getY());



finalState = opensimSimulation.simulate(model, initState, 1.5);

% Analyze a simulation.
disp(coord.getValue(finalState));
model.realizePosition(finalState);
disp(model.calcMassCenterPosition(finalState));
model.realizeAcceleration(finalState);
disp(joint.calcReactionOnParentExpressedInGround(finalState));

reporter_2=StatesTrajectoryReporter.safeDownCast(model.getComponent('states_reporter'))

states=reporter2.getStates()
allStateVars = states.exportToTable(model);

POST REPLY