How to set an external force based on the direction of motion of a joint?

Hi Anybody,

I want to set a resistance to motion, but I don't know how to set a fixed force based on the direction of motion. I hope you can help me.

Thank you in advance.
Chen

Hi Chen,

I am not sure I understand exactly what you want to do. But you can use AnyForce class. If you see the reference manual, this requires an AnyKinMeasure on which the force acts. Depending on kinematic measure you provide, you must provide the same number of force inputs (i.e., the dimension of F must match the dimension of the Pos of the kinematic measure).

This force can be a constant value or a function of time, position, velocity of the kinematic measure. Hopefully, this should allow you define the force as you need it to be.

Best regards,
Dave

Hi Dave,

The study's tStart=0, tEnd=4. If I only want to add an external force in the first 2s, how should I set it.

Thank you in advanceļ¼Œ
Chen

Hi Chen,

There are multiple ways you can do this. For example, you can define a square wave function (AnyFunSquareWave) that can give you a signal 1 within the desired time period and 0 outside that period. Then, you can use this function to modulate the force.

I think the simplest way for you could be to use iffun, gtfun, and ltfun to create such a function yourself. You can access the time variable from within the AnyForce class, so your code could look something like this:

AnyForce3D MyForce = {
    AnyRefFrame &MyRef = <Pointer to your ref frame>
    AnyInt TGT0 = iffun(gtfun(t,0.0),1,0); // 1 if time is greater than 0.0
    AnyInt TLT2 = iffun(ltfun(t,2.0),1,0); // 1 if time is less than 2.0;
    F = {10,0,0}*TGT0*TLT2; // Multiple your force by the two signals
};

Hope this helps

Best regards,
Dave

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