Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
-
Nathan Pickle
- Posts: 12
- Joined: Wed Jan 09, 2013 11:10 am
Post
by Nathan Pickle » Fri Oct 18, 2013 4:17 pm
I'm learning how to use the Matlab scripting functionality, and I'm having trouble running RRA. I have the following code:
Code: Select all
clear all; close all; clc
initialTime = 0.9;
finalTime = 1.94;
import org.opensim.modeling.*
%Create a new model from file
osimModel = Model('Sub01_scripting.osim');
osimModel.setup();
%Initialize the model
state = osimModel.initSystem();
%Create RRA tool from setup file
[fname pname] = uigetfile('.xml','Choose an RRA Setup file');
tool = RRATool([pname fname]);
%Add model to file
tool.setModel(osimModel);
%Run the tool
tool.run();
The tool runs for a little while and then Matlab crashes. In the out.log file, all of the muscles in the model are listed, like it is trying to run CMC instead of replacing the actuator set with the one that I have specified in the setup file. However, if I comment out the line
it runs just fine. There's something about adding the model object to the RRA tool that is causing problems. Can anyone tell me what I'm doing wrong?
-
jimmy d
- Posts: 1375
- Joined: Thu Oct 04, 2007 11:51 pm
Post
by jimmy d » Wed Oct 23, 2013 6:24 pm
Hi Nathan,
Been playing around with acouple of things with the setup. If i pass a file path rather than an object into setModel() It seems to run fine. Perhaps try that and get back to us.
cheers,
-james
-
Nathan Pickle
- Posts: 12
- Joined: Wed Jan 09, 2013 11:10 am
Post
by Nathan Pickle » Thu Oct 24, 2013 8:44 am
Thanks for taking a look at this, James. I'm not sure what you mean about passing a filepath into setModel() - when I try to use a string as an input I get an error saying that
Code: Select all
No method 'setModel' with matching signature found for
class 'org.opensim.modeling.RRATool'.
My current workaround is to use rratool.setModelFilename(filename) to specify the model. Then I print the setup file and reload it into a new rraTool object. This works just fine for what I'm doing, but I am still curious why I can't pass it a model object.
Also, I'm using inverse dynamics through the API with the same model and data and I am able to pass a model object to the IDtool and it will run. Maybe it's a difference between the AbstractTool and Tool classes?
-
jimmy d
- Posts: 1375
- Joined: Thu Oct 04, 2007 11:51 pm
Post
by jimmy d » Thu Oct 24, 2013 1:58 pm
Hey Nathan,
Yep your right, I meant setModelFileName().
So the short of it is this- setModel() is an abstract tool that has a property of stripping the actuators and adding a bunch of controls. As I understand. In ID this doesnt matter because they aren't involved in the calculation of the dynamics. In RRA it is more problematic and behaviour, like you are seeing, occurs.
So dont feed the RRATool() with the setModel() object. Rather (as you are correctly doing) specific the model string name using setModelFileName().
Hope its alittle clearer,
-james