Adding via points programmatically to path spring

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Rejin Varghese
Posts: 16
Joined: Tue Feb 13, 2018 12:22 pm

Adding via points programmatically to path spring

Post by Rejin Varghese » Mon Oct 21, 2024 10:16 pm

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)


Tags:

User avatar
Mohammadreza Rezaie
Posts: 407
Joined: Fri Nov 24, 2017 12:48 am

Re: Adding via points programmatically to path spring

Post by Mohammadreza Rezaie » Wed Oct 23, 2024 9:06 am

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.

User avatar
Rejin Varghese
Posts: 16
Joined: Tue Feb 13, 2018 12:22 pm

Re: Adding via points programmatically to path spring

Post by Rejin Varghese » Thu Oct 24, 2024 5:13 am

Hi Mohammadreza,

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

Regards,

Rejin

POST REPLY