WrapObject Error Message Matlab

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Pelle Heun
Posts: 1
Joined: Tue Oct 12, 2021 4:44 am

WrapObject Error Message Matlab

Post by Pelle Heun » Tue Feb 01, 2022 11:21 am

Hi,
I am having an issue with the code I have created. I am trying to wrap the muscles around the sphere, so they don't clip through the geometry. I am following these posts
viewtopicPhpbb.php?f=91&t=3931&p=16839&start=0&view=
viewtopicPhpbb.php?f=91&t=13193&p=37901&start=0&view=
Even though I copied the code word for word, when I try to open the Model in OpenSim, I receive an error message:
"Failed to connect Socket 'parent_frame' of type PhysicalFrame (details: Connectee for Socket 'parent_frame' of type PhysicalFrame in PathWrapPoint at /forceset/MedialRectus/geometrypath/Eye/pwpt1 is unspecified. If this Model was built programmatically, perhaps finalizeConnections() was not called before printing.
Thrown at Component.h:3345 in finalizeConnections().)
In Object 'pwpt1' of type PathWrapPoint.
Thrown at Component.cpp.313 in finalizeConnections()."

As you can see in the code, I called finalizeConnections(), so I am unsure where the error lies. I could imagine either that the component path is unclear or there is some other issue with adding the wrap object to the muscle.
I would appreciate any input.

Thank you,
Pelle

CODE:
clear all
close all
clc

import org.opensim.modeling.*;

model=Model();
ground=model.getGround();

%% Building Body
eye=Body('Eye',1.0,Vec3(0),Inertia(0));
%Geometry
eyeG=Sphere(0.12);
%eyeG.setColor(Vec3(0.1,0.1,0.1));


eye.attachGeometry(eyeG);
model.addBody(eye);

%Wrap
wrapSphere=WrapSphere();
wrapSphere.setAllPropertiesUseDefault(true);
wrapSphere.setName('NewWrap');
wrapSphere.set_radius(0.12);
wrapSphere.set_quadrant('x');

BodyRef=model.getBodySet().get('Eye');
wrapObjSet=BodyRef.getWrapObjectSet();
wrapObjSet().cloneAndAppend(wrapSphere);


%% Joint
joint=BallJoint('joint',model.getGround(),eye);

rotation_X=joint.upd_coordinates(0);
rotation_X.setRange([-pi, pi]);
rotation_X.setName('rotation_Depth(X)');
rotation_X.setDefaultValue(0);

rotation_Y=joint.upd_coordinates(1);
rotation_Y.setRange([-pi, pi]);
rotation_Y.setName('rotation_Horizontal(Y)');
rotation_Y.setDefaultValue(0);

rotation_Z=joint.upd_coordinates(2);
rotation_Z.setRange([-pi, pi]);
rotation_Z.setName('rotation_Vertical(X)');
rotation_Z.setDefaultValue(0);

model.addJoint(joint);

%% Muscle
%Medial Rectus
MR = Thelen2003Muscle();
MR.setName('MedialRectus')
MR.setOptimalFiberLength(3.19)
MR.setTendonSlackLength(0.491);

MRo=[-0.17,-0.3,0];
MRi=[-0.097,-0.0884,0];
MRp=[-0.14,0.05,0.0014];

MR.addNewPathPoint('MR-Origin', ground, Vec3(MRo(1),MRo(2),MRo(3)))
MR.addNewPathPoint('MR-Pulley', ground, Vec3(MRi(1),MRi(2),MRi(3)))
MR.addNewPathPoint('MR-Insertion', eye, Vec3(MRp(1),MRp(2),MRp(3)))

% add wrap object to muscle
newWrapObj = PathWrap();
newWrapObj.setName('Eye');
newWrapObj.setWrapObject(wrapSphere);

geoPath = MR.getGeometryPath();
wrapSet = geoPath.getWrapSet();
wrapSet.cloneAndAppend(newWrapObj);

model.addForce(MR)

%Lateral Rectus
LR = Thelen2003Muscle();
LR.setName('Lateral Rectus');
LR.setOptimalFiberLength(3.75)
LR.setTendonSlackLength(0.771)

LRo=[-0.13,-0.34,-0.01];
LRi=[0.1008,0.065,0];
LRp=[0.12,-0.08,0.0033];


%% Finalise
model.finalizeFromProperties();
model.finalizeConnections();

model.print

Tags:

POST REPLY