Page 1 of 1

CustomJoint definition with Matlab

Posted: Tue Feb 11, 2014 1:30 am
by miriamfebrer
Hi,

I've been working with a Custom Joint in OpenSim's GUI. Now I'm working
with Matlab because I want to do an interface for doing some analyses for
different types of shoulder prosthesis.

The idea is that for the different types of prosthesis, the functions that
define the spatial transform for this joint will change, and I want to do
this automatically from Matlab. I have a "generic model" (DynamicArms2013 with some changes) , I make a copy, and then I add to the spatial transform of the CustomJoint "shoulder" the functions that define each translation. I have created this example to do
some trials (I will continue working to find the real functions...)

The Spatial Transform I have in the .osim file is the one I've attached in a .xml file.

The idea is to have this Spatial Transform only with the rotational
transform and add the translational transform specified each time. I think
that it will be something like

joints=model.getJointSet();
shoulder_joint= %some function to get the shoulder joint from the set

I think that then I have to update the Spatial Transform spatial_transform = shoulder_joint.updSpatialTransform ()?) creating a variable containing the new Spatial Transform? And then use the function connectToJoint?

Thanks,

Miriam Febrer

Re: CustomJoint definition with Matlab

Posted: Tue Feb 11, 2014 3:38 pm
by jimmy
Hi Miriam,

to access the concrete class 'CustomJoint' you will have to invoke a downcast method.

myModel = Model('c:/.../gait2354.osim')
shoulderJoint = CustomJoint.safeDownCast( myModel.getJoints().get('rightShoulder') );
transformShoulder = shoulderJoint.getSpatialTransform()

At this level you will be manipulating a spatial transofrm object: https://simtk.org/api_docs/opensim/api_ ... 04238ca36a

Hope that helps,
-james

Re: CustomJoint definition with Matlab

Posted: Wed Feb 12, 2014 2:03 am
by miriamfebrer
Thanks, James, it helps a lot!

Now I'm able to do what I wanted.

Thanks,

Miriam

Re: CustomJoint definition with Matlab

Posted: Mon Mar 23, 2015 10:01 am
by melomalaquias
Hi!

I am working with Custom Joints as well, and I am trying to write them completely through Matlab. However I am really struggling with defining the CoordinateSet of them.

In other words, I am looking for something like setCoordinateSet. Can you help me?

Best Regards,

Re: CustomJoint definition with Matlab

Posted: Tue Mar 31, 2015 3:27 pm
by jimmy
Hi Tiago-

CustomJoint, like the all joint types, comes with a prepacked coordinateSet. You would then build a customJoint and customize the coordinates within.

-James

Re: CustomJoint definition with Matlab

Posted: Tue Sep 22, 2015 7:10 am
by kevin_tanghe
jimmy wrote: myModel = Model('c:/.../gait2354.osim')
shoulderJoint = CustomJoint.safeDownCast( myModel.getJoints().get('rightShoulder') );
transformShoulder = shoulderJoint.getSpatialTransform()
How can I do the same thing directly in C++ instead of in Matlab?

Re: CustomJoint definition with Matlab

Posted: Tue Sep 22, 2015 8:02 pm
by nathanbrantly
Thank you very much for this post! I just happened upon it, and it helped me greatly with using the MATLAB API to modify the IKTaskSet in the ScaleTool MarkerPlacer. I thought I would post in case someone happens to run into similar issues and decides to search the forum.

myScaleTool = ScaleTool('...setup_Scale.xml');

I was confused why I couldn't modify the 'Value' and 'ValueType' properties of my IKCoordinateTask using a command such as,

myScaleTool.getMarkerPlacer.getIKTaskSet.get('pelvis_tilt').getValueType

However, I realized from this post that the output of 'get('pelvis_tilt')' is an IKTask object and not a IKCoordinateTask object. I can only access those methods by the following,

pelvisTilt = IKCoordinateTask.safeDownCast(myScaleTool.getMarkerPlacer.getIKTaskSet.get('pelvis_tilt'));
pelvisTilt.getValueType;

Thanks!

Re: CustomJoint definition with Matlab

Posted: Thu Sep 24, 2015 8:23 am
by kevin_tanghe
kevin_tanghe wrote:
jimmy wrote: myModel = Model('c:/.../gait2354.osim')
shoulderJoint = CustomJoint.safeDownCast( myModel.getJoints().get('rightShoulder') );
transformShoulder = shoulderJoint.getSpatialTransform()
How can I do the same thing directly in C++ instead of in Matlab?
I found a solution to this problem:

Code: Select all

OpenSim::JointSet jointSet = osimModel.getJointSet();
OpenSim::Joint *joint = &jointSet.get("rightShoulder");
OpenSim::CustomJoint* shoulderJoint = dynamic_cast<OpenSim::CustomJoint*>(joint);
OpenSim::SpatialTransform transformShoulder = shoulderJoint->get_SpatialTransform();
Please let me know, if this is not the best way to do it.