How to add an external load to my hand node at a given time

Dear AnyBody,

I am researching into Body metabolic rate and fatigue. I am a beginner on AnyBody and I was able to add the load I needed to the hand node, but what I'm going to do is add this load to frames 2500 through 3230 in the BVH file (there are 5000 frames in this bvh file). I tried the method provided in the related post(How to add external load in AnyMocap framework? - #9 by tracy_huang

But the analyzed knot did not change between frame 2500 through 3230. Here is the part of my code

How can I make the load to be time-dependent?

Thank you for any assistance.

Kind regards,

Hi Dylan,

Welcome to the AnyScript forum!

You are almost there. I see two problems for now:

  1. In your interpolation function, T values should extend over the entire time range of the simulation, otherwise you will have an error regarding extrapolation of values, which is not allowed. So, the frames in your T should include the starting and the last frame. Also, the frames in the T don't match your description of 2500-3230. You should change the T in the interpolation function as follows:
T =  {0,2499,2500,3230,3231,5000}*1/240;
  1. F in your AnyForce3D must use the interpolation function. Currently, it is set to a constant value. Please change F as follows:
F = .ForecData.(.t); 

Finally, please note that the force value from the interpolation function is 50N, but you have set -22.5 N in the AnyForce3D. Please make sure that you use the correct value in the interpolation function.

Hope this helps.

Best regards,

Dear Dave,

Thanks for your kind reply and suggestion first. Actually my BVH file has a total of 60,000 frames. But due to lack of computer memory, I only selected frames 12131-14639 to analyze, which is a bending down to put down a water bottle (with a weight of 50N). The way I refer to other posts is to add half the load on each hand.Picking up the water bottle to putting it down is frames 35837 through 36836 in the file。I'm a little confused about what Data's for. Data = { {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 1, 1, 0, 0} }*(-50.0);
Also can you explain me how the interpolating function F = .ForecData.(.t); is used

Here is the code that I changed and changed again

It fails to load after making changes like this

How should I modify it now?

Thank you for your help again.

With Regards,

Hi Dylan,

I see. However, I am not sure what you mean when you say you analyze only frames 12131-14639 but then the force from the water bottle is applied in frames 35837-36836, which are beyond the frames that you are analyzing?

The interpolation function creates a function Data = f(T) from the data points that you provide for T and Data. T is a vector of data points (the parameter - time in your case) and Data can be multidimensional variable dependent on the parameter (force in your case). With this function, you can interpolate to find the variable within the range of points provided for the parameter.

In this example, Data is the force value in x,y,and z components and T is the time converted through frame number and mocap frequency. When you use the function F=.ForecData(.t), you pass the time t from the study as the parameter for the interpolation function and then it provides you the values for force.

I am sorry, there was a typo in my previous post. Please use F = .ForecData(.t);

Best regards

Hi Dave,

Great thanks for your help during this process.My current problem is solved.。 You said "Data is the force value in x,y,and z components "I don't quite understand why there are six numbers inside
{} , // x component
instead of three。Can you assume a direction and give me an example?

I would also like to ask for advice, I would like to replace the model in MetabolicModel2 and then calculate the output to Pmet2 to compare the results with Pmet.

How do I change the model in MetabolicModel2, and how do I do it?
Great thanks for your guidance.

With Regards,

Hi Dylan,

The six numbers in each of x,y,z components correspond to the six values of T. So, if you look at the z component for example,
at T = 34767/240, z = 0*(-22.5)
at T = 35836/240, z = 0*(-22.5)
at T = 35837/240, z = 1*(-22.5)
at T = 36386/240, z = 1*(-22.5)
at T = 36387/240, z = 0*(-22.5)
at T = 36980/240, z = 0*(-22.5)

Likewise, you can make the correspondence between T and x, and y values.
I hope this helps.

Regarding the MetabolicModel2, as you can see in the model tree, the object is there. However not all the settings are written out in the code. Please write the line and set the value yourself. For example, within the scope of your InverseDynamicStudy, type

MetabolicModel2 = ...; // set a metabolic model here

Best regards

Thanks again, the problems regarding the forces have all been solved. I'm still having some problems trying to change the model in MetabolicModel2. I typed in the code
Main.Studies.InverseDynamicStudy.MetabolicModel2 = &MetabolicModels.MetMdlUmberger2010;
But on loading it shows
Loading Main : "D:\Users\JH\Documents\AnyBody.7.4.x\AMMR.v2.4.3-Demo\Application\MocapExamples\BVH_Xsens\Subjects\S3\S03_Trial02\Main.any" Scanning... Parsing... Constructing model tree... ERROR(SCR.PRS9) : AnyMocapModel.any(78) : 'MetabolicModels' : Unresolved object Model loading skipped
Is there still a problem somewhere?

With Regards,

Hi Dylan,

Glad to know that the problems for the forces are resolved.

Regarding the metabolic model, I am sorry I didn't mention the other part before.

As shown in the demo model of Metabolic Models (AnyMetabModel.any) that you had referred to in your previous post, please define the metabolic model in your study. So you would also need the code inside the AnyFolder MetabolicModel:

AnyFolder MetabolicModels = {

I hope this helps.

Best regards

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