cloneAndAppend Wrap Object in MatLab not working

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Alexandra Lancaster
Posts: 3
Joined: Mon Oct 07, 2019 3:06 am

cloneAndAppend Wrap Object in MatLab not working

Post by Alexandra Lancaster » Fri Jun 24, 2022 5:37 am

Hi, I am attempting to locate an existing wrap object in a model and add it to an existing muscle. When I do this I get the following error:

No method 'cloneAndAppend' with matching signature found for class 'org.opensim.modeling.PathWrapSet'.

Does anyone have any insight into what I am doing wrong or if there is a workaround I can use. I have included my code below for clarity.

Code: Select all

muscles = osimModel.getMuscles(); %pulls all the muscles from the model
muscle = muscles.get(muscle_name); %calls specific muscle chosen by muscle_name defined above
WrapAdd = osimModel.getBodySet().get(12).getWrapObjectSet().get(3); %12 represents the body humerus in BodySet and 3 represents humeral_column in WrapObjectSet. for full lists see Untitled_Test.m
        
% add wrap object to muscle
wrapGeoPath = muscle.getGeometryPath(); %Get the muscles geometry where muscle is defined above
wrapSet = wrapGeoPath.getWrapSet(); %Get the muscle's wrap set
        
muscle.getGeometryPath.getWrapSet.cloneAndAppend(WrapAdd); %muscle is previously defined
model.finalizeConnections();
Any advice would be much appreciated

Regards
Alex

Tags:

User avatar
Pasha van Bijlert
Posts: 214
Joined: Sun May 10, 2020 3:15 am

Re: cloneAndAppend Wrap Object in MatLab not working

Post by Pasha van Bijlert » Fri Jun 24, 2022 7:56 am

Hi Alex,

Cross-checking your code with my working solution in this thread you seem to be skipping a step.

You are trying to add a WrapObject (e.g. a cylinder or some other geometry) to the PathWrapSet. OpenSim requires you to create a "PathWrap", in which you specify the object, and then append this to the PathWrapSet.

For your specific situation, what you are calling WrapAdd is the WrapObject. I think the following should work:

Code: Select all

humerus_wrap = PathWrap();
humerus_wrap.setName('whatever') % this is optional
humerus_wrap.setWrapObject(WrapAdd)  %so now you're adding the geometry to the PathWrap

wrapSet.cloneAndAppend(humerus_wrap)
model.finalizeConnections();
This seems convoluted, but I think the reason for this is that it allows you to have multiple muscles using the same wrapping object (by creating separate PathWrap instances using the same wrapping object). Going by the documentation of GeometryPath , it looks like you could skip the above by doing the following:

Code: Select all

muscle.getGeometryPath.addPathWrap(WrapAdd) %WrapAdd is the wrapping object you defined in your first post
Haven't tested it (I hadn't caught this option when I made my own post) but it seems that this is a more straightforward implementation.


Cheers,
Pasha

User avatar
Alexandra Lancaster
Posts: 3
Joined: Mon Oct 07, 2019 3:06 am

Re: cloneAndAppend Wrap Object in MatLab not working

Post by Alexandra Lancaster » Mon Jun 27, 2022 3:57 am

Hi Pasha

Thank you so much for the help, I tried your suggestion of: muscle.getGeometryPath.addPathWrap(WrapAdd) and it worked perfectly!

Thanks so much

Alex

POST REPLY