How to define a spring force?


I defined two AnyRefNodes 1.Main.HumanModel.BodyModel.Right.ShoulderArm.Seg.Humerus.CenterNode_right and
2. Main.Model.EnvironmentModel.UpExo_Right.CenterNode,

I want to define a spring force. The force value depends on the real-time distance between two nodes, like F=500*(distance). The direction of the spring force is the same as the line connecting the two points. Could you tell me how to do it? Thank you!
Best,
TJ

1 Like

Hi @Taejun

You can define a AnyKinLinear measure between the two nodes and then use the .Pos parameter of that measure in your force calculation.

For our bench press demo it can look something like:

AnyForce3D spring = {
    F = {500, 0.0, 0.0} * .WeightHeight.lin.Pos[1];
    AnyRefFrame &weight = .Weight;
};

Best regards,
Bjørn

1 Like

Good morning,

I am trying to build a class_template for CreateSpringForce. But it seems like there are some mistakes in these class_template.
I just swapped the start and end points of the force. In theory, the two forces should be in a straight line, but the simulation results do not. Could you please give me some hints?

CreateSpringForce6DOF SpringForce1(BaseFrame=Main.HumanModel.BodyModel.Right.ShoulderArm.Seg.Humerus.CenterNode_right, TargetFrame=Main.HumanModel.BodyModel.Right.ShoulderArm.Seg.Radius.CenterNode_right, Lenghth=50, k=0.2) = { strength_Scale = 500; };

CreateSpringForce6DOF SpringForce2(BaseFrame=Main.HumanModel.BodyModel.Right.ShoulderArm.Seg.Radius.CenterNode_right, TargetFrame=Main.HumanModel.BodyModel.Right.ShoulderArm.Seg.Humerus.CenterNode_right, Lenghth=50, k=0.2) = { strength_Scale = 500;};


CreateSpringForce6DOF.any (2.0 KB)

Thanks,

Best,
TJ

Hi @Taejun

I think this is related to your other question about the class_template.
Your linear measure in the template use the local refernce system of the the BaseFrame so you get two different coordinate systems. If you set the Ref=-1 you express the linear measure in global coordinates.

Best regards,
Bjørn

1 Like

Great. It works well now! Thanks for everything you have done.

This topic was automatically closed 125 days after the last reply. New replies are no longer allowed.