Matlab error in finding parent body using Opensim 4.2 API
Posted: Tue Jul 06, 2021 1:35 am
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
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