Wrap Object Set with API

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Brad Humphreys
Posts: 79
Joined: Thu Feb 03, 2011 11:32 am

Wrap Object Set with API

Post by Brad Humphreys » Tue Feb 05, 2013 9:59 am

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

User avatar
Ayman Habib
Posts: 2236
Joined: Fri Apr 01, 2005 12:24 pm

Re: Wrap Object Set with API

Post by Ayman Habib » Tue Feb 05, 2013 11:55 am

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

User avatar
Brad Humphreys
Posts: 79
Joined: Thu Feb 03, 2011 11:32 am

Re: Wrap Object Set with API

Post by Brad Humphreys » Tue Feb 05, 2013 3:07 pm

Ayman,

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

Thanks,

Brad

User avatar
Ayman Habib
Posts: 2236
Joined: Fri Apr 01, 2005 12:24 pm

Re: Wrap Object Set with API

Post by Ayman Habib » Wed Feb 06, 2013 10:24 am

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

User avatar
Brad Humphreys
Posts: 79
Joined: Thu Feb 03, 2011 11:32 am

Re: Wrap Object Set with API

Post by Brad Humphreys » Wed Feb 13, 2013 3:08 pm

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

User avatar
Malavika Harikrishnan
Posts: 12
Joined: Wed Mar 02, 2016 9:38 am

Re: Wrap Object Set with API

Post by Malavika Harikrishnan » Mon Apr 04, 2016 7:14 am

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

User avatar
Brad Humphreys
Posts: 79
Joined: Thu Feb 03, 2011 11:32 am

Re: Wrap Object Set with API

Post by Brad Humphreys » Mon Apr 04, 2016 1:36 pm

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

User avatar
Ayman Habib
Posts: 2236
Joined: Fri Apr 01, 2005 12:24 pm

Re: Wrap Object Set with API

Post by Ayman Habib » Mon Apr 04, 2016 1:51 pm

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

User avatar
Malavika Harikrishnan
Posts: 12
Joined: Wed Mar 02, 2016 9:38 am

Re: Wrap Object Set with API

Post by Malavika Harikrishnan » Tue Apr 05, 2016 2:17 am

Thanks for your help

POST REPLY