Using time in AnyFunInterpol for external forces in MoCap model

Hello everybody,

my problem is similar to the problem yoyospace described in October 2014: Adding time dependent external force. The answer to her question did not help me and the link in the answer is dead, so I thought I might rephrase the question as I think this might be interesting for some people.

I’m using the Plug-in-gait Simple Model Fullbody.any of AMMR V2.1.1 and AnyBody 7.2.0. Adding a force which is constant over time is not a problem, as this is described in the AnyBody Tutorials. To add a time variant force, I revised the help on AnyFunInterpol. I added a force to the ankle in the main file after “// Include the anyMoCap Framework” in the following manner:

Main = {
AnyFolder ExternalForce = {
AnyFunInterpol InterpF1 = { // Function for interpolation
Type = Bspline; // Interpolation method
T = {1.56, 2.0, 2.4, 2.75}; // Input value bases
Data = {// Output value bases
{1, 1, 200, 0, -100}, // x
{0, 0, 0, 0, 0}, // y
{0, 0, 0, 0, 0} // z
};// Data
};// AnyFunInterpol InterpF1

  AnyForce3D Force1 = {
     AnyRefNode &AttachForce1  = Main.HumanModel.Right.Leg.Seg.Shank.AnkleJoint; 
     F = Main.ExternalForce.InterpF1(Main.Studies.InverseDynamicStudy.t); // Force in global coordinate system

};// AnyFolder ExternalForce
}; // Main

Main.ModelSetup.TrialSpecificData= {
tStart = 1.56+0.001; // start time of simulation, +0.001 to avoid error of interpolation (“extrapolation is not allowed”)
tEnd = 2.75-0.001; // end time of simulation, -0.001 to avoid error of interpolation (“extrapolation is not allowed”)

For reading convenience, I left out AnyDrawVector in AnyForce3D, though it helps to see the changes in the force value and direction in the simulation.

Now here is my problem: While I am running the simulation, I do not see any changes in the force value. As described by yoyospace previously, the force value is constant over time and appears to be the first value of the data. This can be observed in the 3D model, as the displayed vector is not changing, and in the model tree, as the value of Main.ExternalForce.Force1.F is constant and F = 1.

My first approach for the interpolation input value was to take t, i.e. F = Main.ExternalForce.InterpF1(t). In this case, is assume that t of Force1 is taken, which is 0 at every time step. I did not expect this as I thought time variables of AnyForce3D objects are connected to the t used in the study since it is a denied access member of the object. Why is t not changing?

My next approach was to take the time of the study as seen in the code above, i.e. F = Main.ExternalForce.InterpF1(Main.Studies.InverseDynamicStudy.t). Yet, the value of F still does not change over time, whereas the changes of Main.Studies.InverseDynamicStudy.t can be observed in the model tree during the simulation. I had a look at the help for AnyForce3D again, but the parameter which I assume to control the update behaviour of the class during the calculations, , is a denied access member. However, as interpolation is used throughout the simulation, I assume this parameter is set correctly. At this point I’m stuck. Why doesn’t the force value update? Which time value should I choose for the interpolation?

A side question I also have: Why doesn’t the interpolation work for InterpF1(tStart) and InterpF1(tEnd)?

Thank you in advance for your assistance!

Hi Sebastian!

It sounds indeed like your issue might be similar to what I had and my problem then was that I had not included the force in the inverse dynamics study. If I understand you correctly you have tried to use the time from the inverse dynamics study, but that is not enough. My solution was that I included the force in the ID-study through the file LabSpecificData.any by simply writing:

Main.Studies.InverseDynamicsStudy = {
#include "path_to_forcecode_file.any"

I hope that might solve your problem, and if not, that someone else can help you further :slight_smile:



Hi Maria,

thank you very much for your reply. It works! :slight_smile:
I included the folder ExternalForce in the InverseDynamicStudy Folder by using a pointer as they do with the other folders like the body model, i.e.

Main.Studies.InverseDynamicStudy = {
AnyFolder& ExternalForce= Main.ExternalForce;

So thanks to Maria it's working now. Can someone explain to me why? I'd love to know that!


1 Like

Hi Sebastian,

A model can consist of many objects, and it can have several studies.

Only the objects which are either directly included into a study or referred to from a study will be part of the analysis the study runs.

This makes is possible e.g. to have two studies working on the same body model imposing different motions.

Best regards

1 Like

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