CustomJoint definition with Matlab

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Míriam Febrer-Nafría
Posts: 26
Joined: Thu Apr 18, 2013 4:14 am

CustomJoint definition with Matlab

Post by Míriam Febrer-Nafría » Tue Feb 11, 2014 1:30 am

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
Attachments
CustomJoint.xml
(10.32 KiB) Downloaded 196 times

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

Re: CustomJoint definition with Matlab

Post by jimmy d » Tue Feb 11, 2014 3:38 pm

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

User avatar
Míriam Febrer-Nafría
Posts: 26
Joined: Thu Apr 18, 2013 4:14 am

Re: CustomJoint definition with Matlab

Post by Míriam Febrer-Nafría » Wed Feb 12, 2014 2:03 am

Thanks, James, it helps a lot!

Now I'm able to do what I wanted.

Thanks,

Miriam

User avatar
Tiago Malaquias
Posts: 3
Joined: Fri Jan 16, 2015 8:14 am

Re: CustomJoint definition with Matlab

Post by Tiago Malaquias » Mon Mar 23, 2015 10:01 am

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,

User avatar
jimmy d
Posts: 1375
Joined: Thu Oct 04, 2007 11:51 pm

Re: CustomJoint definition with Matlab

Post by jimmy d » Tue Mar 31, 2015 3:27 pm

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

User avatar
Kevin Tanghe
Posts: 36
Joined: Mon Sep 22, 2014 6:54 am

Re: CustomJoint definition with Matlab

Post by Kevin Tanghe » Tue Sep 22, 2015 7:10 am

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?

User avatar
Nathan Brantly
Posts: 6
Joined: Tue Nov 18, 2014 12:14 pm

Re: CustomJoint definition with Matlab

Post by Nathan Brantly » Tue Sep 22, 2015 8:02 pm

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!

User avatar
Kevin Tanghe
Posts: 36
Joined: Mon Sep 22, 2014 6:54 am

Re: CustomJoint definition with Matlab

Post by Kevin Tanghe » Thu Sep 24, 2015 8:23 am

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.

POST REPLY