Input the external force

Hi, i use the Mocap Example in the repository and i have a CSV file with the bed contact reaction force that syncs with the time of force plates and the BVH file. My subject leans on the bed frame during the task.

So, In the main file, I have defined two AnyRefNode at the bed frame (for left and right leg contact).

I tried to read a column of bed reaction data from CSV and put it inside the F in AnyForce3D as shown:

Main.EnvironmentModel ={
AnyFolder modelbedReac={

   AnyInputFile readcsv = 
   FileName = MOCAP_FP_DATA +"/"+ Main.ModelSetup.TrialSpecificData.TrialFileName + ".csv"; 

     AnyVector Fz= readcsv.Data[2];
     AnyForce3D LeftBedReac= {         
      AnyRefFrame &ref=Main.EnvironmentModel.Bed.NodeLeft0;
      F={0,0, Fz};


There is an error in the F there. May I know how to put the bed reaction column data into F?
Besides, do I need to include interpolation of bed reaction force data since i already sync it with the data from force plates and BVH?
After defining the bed reaction force in the environment model, are there any more settings needed so that the bed reaction force is included in the inverse dynamics?

Hi @Mitchelle_Law

What error do you get ?

You can construct a AnyFunInterpol if you need interpolation of the force.
If you AnyForce3D is included in your study - then the inverse dynamics simulation will pick it up and include it.

Best regards,

Hi Bjorn, the errors are as shown:

ERROR(SCR.EXP0) : BedReac.any(27) : 'F' : Error in expression. Please refer to the following error messages for details ...
ERROR(SCR.EXP1) : BedReac.any(27) : Operator '{' : Illegal operation for given argument types : 'AnyFloat','AnyFloat','AnyFloat[111]'

That is because you are currently trying to assign the whole column of force data into the AnyForce3D and you need something that gives you only one value each timestep.

Something like:

AnyFunInterpol ForceFun = {
  Data = .Fz;
  T = Main.Study.tArray;

AnyForce3D LeftBedReac= {          
  AnyRefFrame &ref=Main.EnvironmentModel.Bed.NodeLeft0;  
  F={0,0, .ForceFun(Main.Study.t)};

For simplification the interpol class can read directly from a comma separated file

Best regards,


Now I faced the errors below, i tried different ways but not work:

ERROR(SCR.PRS9) : BedReac.any(18) : 'BSpline' : Unresolved object

After change to Piecewise Linear:

ERROR(SCR.PRS9) : BedReac.any(17) : 'Study' : Unresolved object

After change study to studies:

ERROR(SCR.PRS9) : BedReac.any(17) : 'tArray' : Unresolved object

After change the T = Main.Studies.InverseDynamicStudy.tArray; and F={0,0, .ForceFun(Main.Studies.InverseDynamicStudy.t)};

ERROR(SCR.EXP0) : BedReac.any(15) : 'ForceFun' : Error in expression. Please refer to the following error messages for details ...
ERROR(SCR.EXP1) : BedReac.any(16) : Operator '=' : Illegal operation for given argument types : 'AnyFloat[ ][ ]' '=' 'AnyFloat[111]'

I have attached the related files just in case. The main file is inside the subjects folder. (899.2 KB)
Please advice.

Hi @Mitchelle_Law

Your error is a type error. The T and Data arrays of the interpol function needs to be the same size.
The error indicates that it is the code on line 16 of the BedReac.any file that is the issue. Please check and try to fix it.

Best regards,

Thanks. I found that the inverse dynamics will take the 3 frames after start time, and 3 frames before the end time of .bvh and force plates CSV file. May i know how to define the time for bed reaction data to follow the same pattern?

You could pop the unneeded frames from your force vector, resample it to the new time steps or use the interpolation function.

Best regards,

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