Page 1 of 1

Issues finding wrapping points of a GeometryPath

Posted: Tue Jan 10, 2023 11:00 am
by finn.eagen
Hello,

This is a follow up to my previous question (here) regarding the geometry path of a spring, but I have run into new issues.

I now have code that is able to successfully find the geometry path of the spring, iterate through, and print out the location of each path point. However, it is only returning the fixed points in the path, ignoring the fact that it curves around a wrap object.

Code: Select all

import org.opensim.modeling.*

% Load model
model = Model('Plot_ThighWrap.osim');
state = model.initSystem();

% Return path point set
springAsForce = model.getForceSet.get('thighBand1');
pathSpring = PathSpring.safeDownCast(springAsForce);
path = pathSpring.get_GeometryPath(); 
pathPointSet = path.getPathPointSet(); 

% Loop through points in muscle path.
for i = 0:pathPointSet.getSize()-1
    pathPoint = pathPointSet.get(i);
    
    % Location of point and body in which it's expressed.
    pathPoint = PathPoint.safeDownCast(pathPoint);
    locInBody = pathPoint.get_location();
    BodyName = pathPoint.getBodyName();

    fprintf('point %d expressed in %s: %s\n', i, BodyName, char(locInBody));
end
Are the coordinates of the wrapping stored somewhere else, if anywhere?

This is all with the end goal of finding the moment created by the spring about the hip; maybe there is a more efficient way to be doing this that I do not know. I saw in the documentation that GeometryPath has .computeMomentArm(), however MatLab said there was no method with matching signature.

Thank you,
Finn

Re: Issues finding wrapping points of a GeometryPath

Posted: Tue Jan 10, 2023 12:54 pm
by ongcf
One of the example Matlab files does use the computeMomentArm() function: https://github.com/opensim-org/opensim- ... ves.m#L157

It's possible that Matlab said there was no matching signature for a couple reasons that could be confusing at first:
1. the number of arguments is incorrect (e.g., passing in 3 arguments when it expects 2)
2. the type of one of the arguments is incorrect (e.g., passing a Joint object rather than a Coordinate object)