Dear all,
I've been practicing to find parent body in OpenSim 4.2 since 'getParent()' command was unfortunately deleted in API 4.0+.
So, I used the code below to find the parent body of 'tibia_r' and get its name:
-----------------------------------------------------
import org.opensim.modeling.*;
clear all; clc;
osimModel = Model('gait2354_simbody.osim');
bodyName = 'tibia_r';
modelJointSet = osimModel.getJointSet();
N_j = modelJointSet.getSize();
for n_j = 0:N_j-1
jointParentName = char(modelJointSet.get(n_j).getParentFrame().findBaseFrame().getName());
end
if strcmp(jointParentName, bodyName)
distalJointSetNames(n_d) = {char(modelJointSet.get(n_j).getName())};
n_d = n_d + 1;
end
-----------------------------------------------------
But unfortunately it showed up the error below:
-----------------------------------------------------
Java exception occurred:
java.lang.RuntimeException: Socket parent_frame of type PhysicalFrame in /jointset/ground_pelvis of type CustomJoint is not
connected.
Thrown at Component.h:3300 in getConnectee().
at org.opensim.modeling.opensimSimulationJNI.Joint_getParentFrame(Native Method)
at org.opensim.modeling.Joint.getParentFrame(Joint.java:161)
-----------------------------------------------------
I tried to use the command "connectSocket_parent_frame()" in my code as I found on Doxygen; but unfortunately, the following error showed up:
No method 'connectSocket_parent_frame' with matching signature found for class 'org.opensim.modeling.Joint'.
-----------------------------------------------------
Now, what can I do to get the parent body name in my case?
Any advice you could give would be much appreciated.
Thanks in advance.
Regards
Matlab error in finding parent body using Opensim 4.2 API
- Sina Tabeiy
- Posts: 8
- Joined: Thu Sep 05, 2019 4:15 am
- Ayman Habib
- Posts: 2248
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Matlab error in finding parent body using Opensim 4.2 API
Hello,
Generally speaking you can't inspect the model structure to find connections etc. until you call initSystem on the model.
Hope this helps,
-Ayman
Generally speaking you can't inspect the model structure to find connections etc. until you call initSystem on the model.
Hope this helps,
-Ayman
- Sina Tabeiy
- Posts: 8
- Joined: Thu Sep 05, 2019 4:15 am
Re: Matlab error in finding parent body using Opensim 4.2 API
Hello Ayman,
Thank you for your speedy and precise answer. It worked properly!
Thank you for your speedy and precise answer. It worked properly!