Missing sockets when adding PointToPointSpring to ForceSet
Posted: Wed May 26, 2021 6:05 am
Hello,
I am trying to add a PointToPointSpring between the hand and the handle of a device in my model and keep this force active when performing RRA. Currently, I can use Matlab to add the springs to the OSIM model just fine, but I cannot get the sockets to print to the XML file being used to replace the forceset for RRA. Below is a copy of what is happening. Any suggestions would be appreciated.
In Matlab I can add to the spring to the OSIM model as such:
This adds this object to the force set in the model file, where all the needed information appears:
This runs, but while the sockets for Body1 and Body2 are set in the Matlab script, they do not print to the XML to create the actuator set:
Thanks for your help,
Evan
I am trying to add a PointToPointSpring between the hand and the handle of a device in my model and keep this force active when performing RRA. Currently, I can use Matlab to add the springs to the OSIM model just fine, but I cannot get the sockets to print to the XML file being used to replace the forceset for RRA. Below is a copy of what is happening. Any suggestions would be appreciated.
In Matlab I can add to the spring to the OSIM model as such:
Code: Select all
hand2handleL = PointToPointSpring();
hand2handleL.setName('L_Hand2Handle');
hand2handleL.set_appliesForce(true);
hand2handleL.setBody1(pfr_Lhandle); % handle
hand2handleL.setBody2(pfr_Lhand); % hand
hand2handleL.setPoint1(HAND_L.getMassCenter()); %coming in as Vec3; handle CoM
hand2handleL.setPoint2(HANDLE_L.getMassCenter()); %coming in as Vec3; hand CoM
hand2handleL.setStiffness(20000); % in N/m; just a guess
hand2handleL.setRestlength(length_L); % in meters, start @ zero --> reset from first walking frame
model.addForce(hand2handleL);
If I do something similar as I create the ForceSet to use when replacing all of the joints with actuators for RRA, I am running this in Matlab:<PointToPointSpring name="L_Hand2Handle">
<!--Flag indicating whether the force is applied or not. If true the forceis applied to the MultibodySystem otherwise the force is not applied.NOTE: Prior to OpenSim 4.0, this behavior was controlled by the 'isDisabled' property, where 'true' meant that force was not being applied. Thus, if 'isDisabled' is true, then 'appliesForce` is false.-->
<appliesForce>true</appliesForce>
<!--Path to a Component that satisfies the Socket 'body1' of type PhysicalFrame (description: A frame on the first body that this spring connects to.).-->
<socket_body1>/bodyset/LHandle</socket_body1>
<!--Path to a Component that satisfies the Socket 'body2' of type PhysicalFrame (description: A frame on the second body that this spring connects to.).-->
<socket_body2>/bodyset/hand_l</socket_body2>
<!--Spring attachment point on body1.-->
<point1>0 -0.068095000000000003 0</point1>
<!--Spring attachment point on body2.-->
<point2>0 0.019900000000000001 -0.0071999999999999998</point2>
<!--Spring stiffness (N/m).-->
<stiffness>20000</stiffness>
<!--Spring resting length (m).-->
<rest_length>0.11847819597001483</rest_length>
</PointToPointSpring>
Code: Select all
hand2handleL = PointToPointSpring();
hand2handleL.setName('L_Hand2Handle');
hand2handleL.set_appliesForce(true);
hand2handleL.setBody1(pfr_Lhandle); % handle
hand2handleL.setBody2(pfr_Lhand); % hand
hand2handleL.setPoint1(L_hand.getMassCenter()); %coming in as Vec3; handle CoM
hand2handleL.setPoint2(lhandle.getMassCenter()); %coming in as Vec3; hand CoM
hand2handleL.setStiffness(20000); % in N/m; just a guess
hand2handleL.setRestlength(length_L); % in meters, start @ zero --> reset from first walking frame
forceSet.cloneAndAppend(hand2handleL);
If I copy the "socket_body" objects from the model to the actuators XML, RRA runs and the springs at the hands behave as expected. I cannot find any info on why this is working in the model force set, but not when printing the XML. Does anyone have any ideas on how to solve this? It would be really useful to be able to generate the XML completely programatically.<PointToPointSpring name="L_Hand2Handle">
<!--Flag indicating whether the force is applied or not. If true the forceis applied to the MultibodySystem otherwise the force is not applied.NOTE: Prior to OpenSim 4.0, this behavior was controlled by the 'isDisabled' property, where 'true' meant that force was not being applied. Thus, if 'isDisabled' is true, then 'appliesForce` is false.-->
<appliesForce>true</appliesForce>
<!--Spring attachment point on body1.-->
<point1>0 -0.068095000000000003 0</point1>
<!--Spring attachment point on body2.-->
<point2>0 0.019900000000000001 -0.0071999999999999998</point2>
<!--Spring stiffness (N/m).-->
<stiffness>20000</stiffness>
<!--Spring resting length (m).-->
<rest_length>0.11847819597001483</rest_length>
</PointToPointSpring>
Thanks for your help,
Evan