GRF Prediction and Inverse Dynamics Problems

Hi there,

I’ve been using AnyBody for 2 weeks and don’t have that much time left to produce results. I’ve been through most of the tutorials, webcasts and have searched all over the forum however I’m still finding it difficult to tailor the AnyScript code to my needs. I have a few problems which I’m stuck on:

  1. Why am I getting muscle recruitment aborted error when running Inverse Dynamics and how do I fix it? Also what’s up with the warnings?

  2. How do I change the GRF Prediction code (located in the GRFPrediction folder in the model folder - see attached) to refer to nodes on the pelvis instead of the feet? I just can’t for the life of me figure out how to do it. There’s currently 25 nodes on the foot but how do I change this to be the pelvis?

Background: the subject is seated on a bicycle seat and is pedalling their legs in a cyclic motion using a linkage system. The motion of one leg is independent of the other (the two pedals are not attached to each other like in a normal bicycle). The seat is fixed to a frame which is placed on the ground.

I’m manipulating these files in the Input folder to bypass using the markers (I’m driving motion via joint angles):
FullBody-GaitNormal_1-euler-trunk.txt
FullBody-GaitNormal_1-euler-rightlegtd.txt
FullBody-GaitNormal_1-euler-leftlegtd.txt
FullBody-GaitNormal_1-euler-rightarm.txt
FullBody-GaitNormal_1-euler-leftarm.txt

Note: From the encoders of the device I’m using, there’s only hip flexion and knee joint angle data, which is present in the files above (the rest of the segments are set to 0 for each time instance).

Then I’m directly running Inverse Dynamics but need to fix GRF Prediction and the muscle recruitment aborted error before I can continue.

Attached are my model files, I am using MoCap_FullBody.main.any

I would greatly appreciate any help with this.

Kind regards,

Jared

Dear Jared,

Please find attached a working version of your model. In your main folder, you will see a file called “IndexOfChanges.any” that will direct you to the files where I have made any changes. Skim through the files and find the comments relating to the changes I’ve made

  1. Your muscle recruitment errors were because you entered joint angles in degrees and not radians. I think this may put the model in some very awkward, non-anatomical postures where muscle moment arms were unfavourable. I have fixed this in Changes numbered 1 and 2 in “IndexOfChanges.any”.

  2. I have demonstrated the modification of the GRF prediction code for your seat, in Change #3. I have only created one contact node on the pelvis for now, but you are free to add as many as you’d like within reason.

When you have created links/segments for the two pedals, you should add GRF prediction for the two feet as well, using standard procedure. Hope this helps!

Regards
Ananth
AnyBody Support

Hi there,

Thank you for helping me, I have reviewed the model and am now plotting different graphs via the Chart window. I have a few questions:

  1. What are the units for muscle strength in the AnyBody plots?

  2. For MaxMuscleActivity (see picture of graph attached), why is the y axis 1.0e+000 instead of 1.0e-001?? Do I read off the graph as such: the body uses 18.2% of its maximum strength? Keep in mind this is for a seated subject moving their feet in a cyclic manner.

  3. Is it possible to use AnyBody in real time? For my model, AnyBody is using output text files from a MATLAB script (the MATLAB script uses input text files from encoders). Ideally I want to view a live feed of the muscle forces / joint position graphs in AnyBody when the encoder position changes. However there’s a few manual features such as the tEnd variable for the Inverse Dynamics study which I’m not sure how to automate.

I have made a Simulink model which reads in from encoders (via text files) and outputs text files for use as input to my AnyBody model. I have also written a script that reads in the .h5 data file containing the output from the I.D. analysis. However, how exactly do I get AnyBody to perform Inverse Dynamics in real time with the Simulink model?

Kind regards,

Jared

I am getting this error when I try InverseDynamicAnalysisSequence with different input data:

Macro command : InverseDynamicAnalysisSequence(8:9)> run

8.0) InverseDynamics (Operation: Main.Studies.InverseDynamicStudy.InverseDynamics):
8.0.0) PreOperation (Operation: Main.Studies.InverseDynamicStudy.InverseDynamics.PreOperation):
8.0.0.0) InitialConditions (Operation: Main.Studies.InverseDynamicStudy.InitialConditions):
8.0.0.0) ...Design variables have been updated.
8.0.0.1) ...Load-time positions have been re-established.
8.0.0.2) ...Kinematic analysis completed. The kinematic constraints have been resolved.
8.0.0.3) ...Initial conditions are fully updated.
8.0) Inverse dynamic analysis...
ERROR(OBJ.MCH.MUS4) : I:/S..r/A..y/N..l/R..l/M..l/InverseDynamics.any(29) : InverseDynamicStudy.InverseDynamics : Muscle recruitment solver : solver aborted after maximum number of iterations

All I did was load a different trial of data into the Input folder:

FullBody-GaitNormal_1-euler-leftarm.txt
FullBody-GaitNormal_1-euler-leftlegtd.txt
FullBody-GaitNormal_1-euler-rightarm.txt
FullBody-GaitNormal_1-euler-rightlegtd.txt
FullBody-GaitNormal_1-euler-trunk.txt

Then I set the Mannequin.any script to the initial position in the Model folder.

How come I'm getting this error? Do I have to run some optimisation prior to going straight to Inverse Dynamics? I'm so confused.

Attached is the exact same model folder you sent me, the only difference being the FullBody-GaitNormal_1-euler text files are different. I also changed the tEnd variable in InverseDynamics.any to the appropriate time value.

Hi Jared,

  1. The muscle strength is typically in Newtons. However there is a concept of “virtual muscles” implemented using the AnyGeneralMuscle class. In these cases the units would depend on the type of kinematic measure associated with the muscle. So if it was a rotational measure, the force units would be Nm, but just N for a linear measure.

  2. Nope. The maximum muscle activity is the maximum activity seen over all muscles in your model. i.e the most active muscle in your body during seated cycling, is using 18.2% of its full potential.

  3. AnyBody currently does not support any real-time feature.

I’ll take a look at the other files you shared and let you if I find out why it crashed.

Regards
Ananth

Hi Jared,

Your new set of files are failing due to the same reasons why your first set failed.

Please check the comments I made for you in the model that I modified, and convert your joint angles to radians.

Regards
Ananth

Hi Ananth,

In the model you prepared for me, you made changes in JointsAndDriversOptimized.any to convert my input text files of joint angles in degrees, to radians.

So when I input a new set of text files in degrees, shouldn't your model handle the conversion to radians?

I modified your model: in JointsAndDriversOptimized.any, I commented out your degrees to radians conversion and modified my MATLAB script to create the text files in radians rather than degrees, which I then copied to the Input folder. In the Mannequin.any script, it seems to be reading in the initial posture in degrees from my modified text files in the Model folder (which is why my text files in the Model file are in degrees).

When I load the model and run InverseDynamicAnalysisSequence, I get this error still:

8.0) Inverse dynamic analysis...
ERROR(OBJ.MCH.MUS4) : //u..z/e..s/home/j..1/D..p/A..y/M..h/M..h/M..l/InverseDynamics.any(29) : InverseDynamicStudy.InverseDynamics : Muscle recruitment solver : solver aborted after maximum number of iterations

Macro command : InverseDynamicAnalysisSequence(9:9)> classoperation Main.Studies.InverseDynamicStudy.Output"Save data" --file=../Output/FullBody-GaitNormal_1.anydata.h5 --type=Deep

Main.Studies.InverseDynamicStudy.Output : Saving output data file...
...saving succeed.
Elapsed Time :5.538

Attached is the modified model

I’ve noticed why it’s not working, but don’t know how to fix it.

When I load new input files into the Input folder and go directly to InverseDynamicAnalysisSequence, it gives me errors because I haven’t updated the text file, FullBody-GaitNormal_1-OptimizedParameters.txt, in the Input file.

However, if I open the model you revised, and run ParameterOptimization operation, I can view the motion in the Model View however I get all of these errors:

http://pastebin.com/hd96kTBm

My question is, how do I update OptimizedParameters.txt for any input files of joint angles in order to properly run InverseDynamicAnalysisSequence without errors?

The issue isn’t with the input files as you got it working with one set of my data. I can’t seem to fix this :frowning:

The problem: I don’t know what to do before running InverseDynamicAnalysisSequence with a new set of input joint angles

It should still work with other input data of the same units. The Input folder text files are converted to radians in your revised script, and the Mannequin.any script reads in the first column of each text file in the Model folder in degrees (if I change these to radians, the posture of the model is in radians, which is the wrong orientation observed in model view)

Dear Jared,

You are right, I missed the fact that I’d set the degrees to radian conversion in the Anyscript :slight_smile:

You do not need to run parameter optimization for this model since you are directly provding the joint angles, without relying on any marker data. So the model should theoretically be able to assume any orientation where the joint angles are within limits irrespective of segment lengths etc.

After investigating more, the problem is still with the input file you have provided. In the origina RGT_Model that you shared, if I look at the joint angle inputs they seem extremely noisy. Here’s a sample:

0.005000 18.360307 0 0 51.214199 0 0
0.006000 18.279386 0 0 51.014182 0 0
0.007000 18.279386 0 0 51.014182 0 0
0.008000 18.457125 0 0 51.201836 0 0
0.009000 18.306420 0 0 51.080958 0 0
0.010000 18.279386 0 0 51.014182 0 0
0.011000 18.279386 0 0 51.014182 0 0
0.012000 18.295671 0 0 51.011658 0 0
0.013000 18.279386 0 0 51.014182 0 0
0.014000 18.279386 0 0 51.014182 0 0
0.015000 18.168644 0 0 50.780999 0 0

You have the exact same joint angle for 0.006 and 0.007 seconds. Also the hip angle increaeses from 0.011 to 0.012 seconds, before decreasing and increasing again at 0.015 seconds. So the interpolation driver interpolates Bsplines which end up having super high second derivatives (accelerations) which the muscles are incapable of providing. Hope this helps :slight_smile:

Regards
Ananth

I added a low pass filter in my MATLAB script which made Inverse Dynamics work perfectly in AnyBody.

Thanks for the help, Ananth!

Kind regards,

Jared