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
Editing Path Point attachments
- Hilary Cheng
- Posts: 12
- Joined: Thu Oct 04, 2018 9:10 pm
Re: The input of Command. Opensim API
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;
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');
- Hilary Cheng
- Posts: 12
- Joined: Thu Oct 04, 2018 9:10 pm
Re: Editing Path Point attachments
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
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