Editing Path Point attachments

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Hilary Cheng
Posts: 12
Joined: Thu Oct 04, 2018 9:10 pm

Editing Path Point attachments

Post by Hilary Cheng » Wed Feb 27, 2019 1:53 am

Hi,

I am trying to use the function below from the Opensim API in Matlab.

updateFromXMLNode (SimTK::Xml::Element & aNode, int versionNumber)

I would like to change the frame of an Abstract PathPoint and get an update of its point coordinate.

I am wondering what should be the inputs for the above function?
What is the Element that I need and what means by versionNumber?


Many Thanks!!!

Hilary

Tags:

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

Re: The input of Command. Opensim API

Post by jimmy d » Wed Feb 27, 2019 9:59 am

UpdateFromXMLNode is an internal function that helps translate setup files (written in XML) to objects in memory-- by design, you won't be able to use it in Matlab.

If you want to change the body/frame of a path point in Matlab you could do something like the following;

Code: Select all

import org.opensim.modeling.*
model = Model('Arm26.osim')

% Get a muscle
muscle = model.getForceSet().get(1);
% Get the concrete class of this muscle
mus = Thelen2003Muscle.safeDownCast(m);
% Get the Geometry Path
gp = mus.getGeometryPath();
% Get the PathPointSet
pps = gp.getPathPointSet();
% Get the  AbstractPathPoint
pp = pps.get(0);
% Get the Concrete Class PathPoint
p = PathPoint.safeDownCast(pp);

% Get a different body in the the model
b = model.getBodySet().get('r_ulna_radius_hand');

% Change the body for this pathpoint
p.setBody(b);

% Rebuild the system
model.initSystem();

% Write the model to file
model.print('arm26_4_2.osim');


User avatar
Hilary Cheng
Posts: 12
Joined: Thu Oct 04, 2018 9:10 pm

Re: Editing Path Point attachments

Post by Hilary Cheng » Wed Feb 27, 2019 8:34 pm

Thanks for your reply!

After changing the new PathPoint frame, I would like to get the updated PathPoint Location with respected to the newly assigned frame.

In the p = PathPoint.safeDownCast(pp) function, p becomes an empty set if pp is a MovingPathPoint.

I ran the code below in Matlab to update the Location. I can successfully update the fixed PathPoint Location but not MovingPathPoint.
p = PathPoint.safeDownCast(pp)
p.changeBodyPreserveLocation(State,dsrFrame);


Thanks so much for helping!

Hilary

POST REPLY