Issue importing geometry bodies in Matlab

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Kirstie Devin
Posts: 6
Joined: Fri Mar 27, 2020 3:06 am

Issue importing geometry bodies in Matlab

Post by Kirstie Devin » Mon Jul 20, 2020 8:37 am

I'm currently trying to create my own model using pre-defined geometries. However, I keep getting the following message whenever I try to import the pelvis geometry:

Code: Select all

Error using BGSM (line 269)
Java exception occurred:
java.lang.RuntimeException: ArrayPtrs.get(aName): No object with name r_pelvis

	at org.opensim.modeling.opensimSimulationJNI.SetBodies_get__SWIG_1(Native Method)

	at org.opensim.modeling.SetBodies.get(SetBodies.java:149)
I have tried calling 'pelvis', 'l_pelvis' and so on, and it seems I am able to import the basic files as per the dynamic walker example, but I don't want to use a sphere to represent the pelvis.

Here is my code:

Code: Select all

pelvis  = Body();                                        % Creates a body
massCenter = Vec3(-0.0707,0.0,0.0);                       % Create a Vec3 Object with mass center information
inertia = Inertia(0.128, 0.0871, 0.0579, 0, 0, 0);        % Create an Inertia object with only principal axes
pelvis.setName('Pelvis');                                % Set the name of the body
pelvis.setMass(pelvisMass);                                      % Set the mass of the body
pelvis.setMassCenter(massCenter);                        % Set the mass center
pelvis.setInertia(inertia);                              % Set the body's inertia
r_pelvis = model.getBodySet().get('r_pelvis'); 
pelvis = pelvis.attachGeometry(pelvis);
osimModel.addBody(pelvis);
Alternatively, is there any way of me constructing this geometry using markers? I created a marker file, but when I tried to apply it to an osim model, it rejected it as it said there are too many markers. I don't know how to go around this.

Any help would be much appreciated. Thank you in advance!

Tags:

User avatar
Kirstie Devin
Posts: 6
Joined: Fri Mar 27, 2020 3:06 am

Re: Issue importing geometry bodies in Matlab

Post by Kirstie Devin » Mon Jul 20, 2020 8:51 am

Also, it's worth mentioning that when I try to import the gait2392 or gait2354 model, I get the following message in MATLAB:

Code: Select all

Error using BGSM (line 39)
Java exception occurred:
java.io.IOException: Object: Cannot open file gait2392_simbody.osim. It may not exist or you do not have
permission to read it.
	Thrown at Object.cpp:105 in Object().

	at org.opensim.modeling.opensimSimulationJNI.new_Model__SWIG_1(Native Method)

	at org.opensim.modeling.Model.<init>(Model.java:783)
I don't understand why this is the case, any ideas? Thanks!

User avatar
Ayman Habib
Posts: 2248
Joined: Fri Apr 01, 2005 12:24 pm

Re: Issue importing geometry bodies in Matlab

Post by Ayman Habib » Mon Jul 20, 2020 10:19 am

Hello,

Not sure what was your intention in this line

Code: Select all

pelvis = pelvis.attachGeometry(pelvis);
Earlier you defined "pelvis" as a Body and now you are trying to use it as a Geometry object and attaching it to itself. Also the method attachGeometry does not return a Body to assign to 'pelvis'.

I strongly recommend that you study the provided example scripts here https://simtk-confluence.stanford.edu/d ... ith+Matlab to help you use the API before jumping into model building

As to your second question regarding "can't open file", this has to do with your current working directory in Matlab, please change the working directory in Matlab to the one containing the model files, or use a full path name to the model file if you prefer not to change your working directory.

Hope this helps,
-Ayman

User avatar
Kirstie Devin
Posts: 6
Joined: Fri Mar 27, 2020 3:06 am

Re: Issue importing geometry bodies in Matlab

Post by Kirstie Devin » Mon Jul 20, 2020 11:54 am

Hi Ayman,

Thanks for your help - I didn't realise that is what I was doing. I was trying to follow the example as per dynamic walker model, but was trying to edit the model/apply my own parameters and model properties.

With respect to importing the gait2354 file, I've managed to do it by setting the directory to the path to 'OpenSim\4.1\Models\Gait2354_Simbody\gait2354_simbody.osim'. I had originally placed copies of this in the 'code' section, and matlab didn't seem to like that (again, this was likely caused by an error on my part).

Thank you for your help! :D

POST REPLY