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
CustomJoint definition with Matlab
- Míriam Febrer-Nafría
- Posts: 26
- Joined: Thu Apr 18, 2013 4:14 am
CustomJoint definition with Matlab
- Attachments
-
- CustomJoint.xml
- (10.32 KiB) Downloaded 195 times
Re: CustomJoint definition with Matlab
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
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
- Míriam Febrer-Nafría
- Posts: 26
- Joined: Thu Apr 18, 2013 4:14 am
Re: CustomJoint definition with Matlab
Thanks, James, it helps a lot!
Now I'm able to do what I wanted.
Thanks,
Miriam
Now I'm able to do what I wanted.
Thanks,
Miriam
- Tiago Malaquias
- Posts: 3
- Joined: Fri Jan 16, 2015 8:14 am
Re: CustomJoint definition with Matlab
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,
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
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
CustomJoint, like the all joint types, comes with a prepacked coordinateSet. You would then build a customJoint and customize the coordinates within.
-James
- Kevin Tanghe
- Posts: 36
- Joined: Mon Sep 22, 2014 6:54 am
Re: CustomJoint definition with Matlab
How can I do the same thing directly in C++ instead of in Matlab?jimmy wrote: myModel = Model('c:/.../gait2354.osim')
shoulderJoint = CustomJoint.safeDownCast( myModel.getJoints().get('rightShoulder') );
transformShoulder = shoulderJoint.getSpatialTransform()
- Nathan Brantly
- Posts: 6
- Joined: Tue Nov 18, 2014 12:14 pm
Re: CustomJoint definition with Matlab
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!
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!
- Kevin Tanghe
- Posts: 36
- Joined: Mon Sep 22, 2014 6:54 am
Re: CustomJoint definition with Matlab
I found a solution to this problem:kevin_tanghe wrote:How can I do the same thing directly in C++ instead of in Matlab?jimmy wrote: myModel = Model('c:/.../gait2354.osim')
shoulderJoint = CustomJoint.safeDownCast( myModel.getJoints().get('rightShoulder') );
transformShoulder = shoulderJoint.getSpatialTransform()
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();