Page 1 of 1

Adding via points programmatically to path spring

Posted: Mon Oct 21, 2024 10:16 pm
by rejinjv
Hi experts,

Could I ask how to specifically set intermediate points on a geometry path as via points. Once I add a path spring to the model, in the GUI I am able to toggle between fixed, moving and via points for the points in the path of the path spring. How do I do the same programmatically in MATLAB ? The snippet of the code I use to initialise the path spring and add the path of the geometry is below. I want to make the intermediate two points as via points. Is that automatically done internally since its a single continuous path ? Or do I need to explicitly mention that I want to make the intermediate points via points.

Thank you for all your help.

Regards,

Rejin

Code: Select all

% Create Path Actuator between selected marker locations
syringeActuator = PathSpring();
syringeActuator.setName('syringeActuator');

% Set the location of the first point in the tibia frame. These numbers
% were determined from placing a marker on the desired location in the GUI.
syringeActuator.getGeometryPath().appendNewPathPoint('tibiaLoc',tibia,tibiaMarkerLoc);
% Set the locaton of the second point in the tibia frame
syringeActuator.getGeometryPath().appendNewPathPoint('calcnLoc', calcn,calcnMarkerLoc);
% Set the locaton of the second point in the tibia frame
syringeActuator.getGeometryPath().appendNewPathPoint('foot1Loc', calcn,footMarker1Loc);
% Set the locaton of the second point in the tibia frame
syringeActuator.getGeometryPath().appendNewPathPoint('tibia2Loc', tibia,tibiaMarker2Loc);


% Path Spring Characteristics
syringeActuator.setStiffness(0);
syringeActuator.setDissipation(0);
% pathSpringRestingLength = calcnMarker.calcDistanceBetween(state,tibia,tibiaMarker.get_location());
syringeActuator.setRestingLength(pathSpringRestingLength);


% Add the force to the model
model.addForce(syringeActuator);
model.finalizeConnections();

% print model - save as new file
model.print(modfilename)


Re: Adding via points programmatically to path spring

Posted: Wed Oct 23, 2024 9:06 am
by kernalnet
Hi, once you created your via point through ConditionalPathPoint object, you can add it to the PathSpring as follows:

Code: Select all

via = ConditionalPathPoint()
via.setName('via')
...
syringeActuator.getGeometryPath().getPathPointSet().cloneAndAppend(via)
Hope this helps.

Re: Adding via points programmatically to path spring

Posted: Thu Oct 24, 2024 5:13 am
by rejinjv
Hi Mohammadreza,

Thanks for the quick reply. I will try this code out.

Regards,

Rejin