Page 1 of 1

Wrap Object Set with API

Posted: Tue Feb 05, 2013 9:59 am
by bradh
With the beta 3.0.1, I have been able to add joint types, muscles, and actuators (Torque and Force). It was mentioned that wrap objects can also be used. I do not see a means to do this (i.e. addWrapObject or add WrapObjectSet). Do wrap objects sets need to be created when the body is created or is it possible to add warp objects to a body?

If you have some API code in MATLAB or Python demonstrating how to add a wrap object, it would be much appreciated.

Thanks!

The additions to 3.0.1 have been incredibly helpful!

Brad

Re: Wrap Object Set with API

Posted: Tue Feb 05, 2013 11:55 am
by aymanh
Hi Brad,

You can call

Code: Select all

wrapObjectSet = b.getWrapObjectSet()
and then you can apply the "set" methods to

Code: Select all

wrapObjectSet.cloneAndAppend(...)
new WrapObjects as needed.

Please let me know how that works or if you have any questions.

-Ayman

Re: Wrap Object Set with API

Posted: Tue Feb 05, 2013 3:07 pm
by bradh
Ayman,

How do I create a WrapObject from scratch (in a model where no objects exist to be cloned)?

Thanks,

Brad

Re: Wrap Object Set with API

Posted: Wed Feb 06, 2013 10:24 am
by aymanh
Hi Brad,

WrapObject is a base class, the concrete classes you can construct are WrapSphere, WrapCylinder, ...

in C++ syntax you'd call

Code: Select all

cyl = new WrapCylinder(); cyl.setRadius(.5); cyl.setLength(1.0);
In Python/Matlab you don't use "new" but you can call the same methods. Please let me know if that takes care of your needs. We don't have many examples that create WrapObjects programmatically, so it would be great to know if the interface is complete or if not what's missing.

All the best,
-Ayman

Re: Wrap Object Set with API

Posted: Wed Feb 13, 2013 3:08 pm
by bradh
Ayman,

Thanks, I was able to use the appendAndClone to create a wrap on a body. I was also able to add it to a muscle's wrap set. There does seem to be some methods missing that are needed for the the body wrap: setTranslation, setXyz_body_rotation, and setActive.
Also when I add the Wrap to the muscle I can not use the setMethod because I get: TypeError: setMethod(): 1st arg can't be coerced to org.opensim.modeling.PathWrap$WrapMethod (not sure of how to create that type).


For reference the Code I used:

Build the Cylindrical Wrap on the body:

Code: Select all

wrapCyl=modeling.WrapCylinder()  #Create a new wrap object
wrapCyl.setAllPropertiesUseDefault(True)
wrapCyl.setName('NewWrap')
wrapCyl.setRadius(1)
wrapCyl.setLength(1)
wrapCyl.setQuadrantName('x')

BodyRef=model.getBodySet().get('NameOfBodyToAddTo')
wrapObjSet=BodyRef.getWrapObjectSet()
wrapObjSet.cloneAndAppend(wrapCyl)
Build the Muscle (muscle1), not shown here.

Then add the wrap to the muscle's wrap set:

Code: Select all

#Create the Muscle Wrap Object
newWrapObj=modeling.PathWrap()
newWrapObj.setName('NewWrapObj')
#newWrapObj.setMethod('hybrid')           #Can not set the method here.   
newWrapObj.setWrapObject(wrapCyl)

geoPath=muscle1.getGeometryPath()  #Get the muscles geometry
wrapSet=geoPath.getWrapSet()           #Get the muscle's wrap set
wrapSet.cloneAndAppend(newWrapObj)   #Add the wrap created above to the muscles wrap set
I also tried creating moving and via Path Points (modeling.MovingPathPoint() and modeling.ConditionalPathPoint()). They seem to be missing several needed methods though: setXCoordinateName, setXFunction, setXCoordinate, setBody (and the 'y' and 'z').

Hope this helps and any feedback that you have would be great.

Brad

Re: Wrap Object Set with API

Posted: Mon Apr 04, 2016 7:14 am
by malavika
Hey Ayman and Bradh,

Is there now an update to the missing methods for body wrap like setTranslation, rotation xyz etc?
If so, Please share the matlab syntax for the same

Thanks in advance
Malavika

Re: Wrap Object Set with API

Posted: Mon Apr 04, 2016 1:36 pm
by bradh
Malavika,

I did not get any further than my responses here as my reason for doing this went away due to taking a different approach unrelated to the wrap surface. Since then I have not needed to programmaticly create a wrap surface.

Regards,

Brad

Re: Wrap Object Set with API

Posted: Mon Apr 04, 2016 1:51 pm
by aymanh
Hi all,

Please refer to the thread below for a workaround. We haven't modified the wrapping API pending major refactoring that will likely happen after the next major release. Hope this helps.

https://simtk.org/forums/viewtopic.php?f=91&t=6123

Best regards,
-Ayman

Re: Wrap Object Set with API

Posted: Tue Apr 05, 2016 2:17 am
by malavika
Thanks for your help