Wrap Object Set with API
- Brad Humphreys
- Posts: 79
- Joined: Thu Feb 03, 2011 11:32 am
Wrap Object Set with API
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
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
- Ayman Habib
- Posts: 2240
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Wrap Object Set with API
Hi Brad,
You can call and then you can apply the "set" methods to new WrapObjects as needed.
Please let me know how that works or if you have any questions.
-Ayman
You can call
Code: Select all
wrapObjectSet = b.getWrapObjectSet()
Code: Select all
wrapObjectSet.cloneAndAppend(...)
Please let me know how that works or if you have any questions.
-Ayman
- Brad Humphreys
- Posts: 79
- Joined: Thu Feb 03, 2011 11:32 am
Re: Wrap Object Set with API
Ayman,
How do I create a WrapObject from scratch (in a model where no objects exist to be cloned)?
Thanks,
Brad
How do I create a WrapObject from scratch (in a model where no objects exist to be cloned)?
Thanks,
Brad
- Ayman Habib
- Posts: 2240
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Wrap Object Set with API
Hi Brad,
WrapObject is a base class, the concrete classes you can construct are WrapSphere, WrapCylinder, ...
in C++ syntax you'd call
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
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);
All the best,
-Ayman
- Brad Humphreys
- Posts: 79
- Joined: Thu Feb 03, 2011 11:32 am
Re: Wrap Object Set with API
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:
Build the Muscle (muscle1), not shown here.
Then add the wrap to the muscle's 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
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)
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
Hope this helps and any feedback that you have would be great.
Brad
- Malavika Harikrishnan
- Posts: 12
- Joined: Wed Mar 02, 2016 9:38 am
Re: Wrap Object Set with API
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
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
- Brad Humphreys
- Posts: 79
- Joined: Thu Feb 03, 2011 11:32 am
Re: Wrap Object Set with API
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
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
- Ayman Habib
- Posts: 2240
- Joined: Fri Apr 01, 2005 12:24 pm
Re: Wrap Object Set with API
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
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
- Malavika Harikrishnan
- Posts: 12
- Joined: Wed Mar 02, 2016 9:38 am
Re: Wrap Object Set with API
Thanks for your help