Including forces to MoCap Fullbody

Hi AnyBody,

I use the MoCap Fullbody Model for simulating a movement of lifting a box.
I would like to define two external forces at the hands.
Everything is alright but I have a question:
Where can I determine the timing of the start and end of force application? And which function should I use?

Thanks in advance.

Rena

Hi Rena,

I am not sure if I understand your problem correctly. I think the times when you apply the forces you have to determine on your own as long as they are not part of the c3d file. To get the times of the data from the c3d, you can have a look in ModelSetup.any and then Times.any, where tStart and tEnd are defined on frames of the c3d.

If you want to switch forces on and off, I would multiply the force vector of the AnyForce class of your choice with an indicator function, e.g. an AnyFunSquareWave or AnyFunInterpol, which takes the time as input.

Best regards
Daniel

Hi Daniel,

Thanks for the feedback!
I have no force data for my motion data, so I have to include them manually.
The problem is:
The c3d file begins with frame 40 and ends with frame 501
But the attack of force an the hands should only be from frame 117 to 456. Is this possible to simulate with AnyFunSquareWave or AnyFunInterpol?

I use the full body motion capture. Is it useful to define the forces in the environment or should the definition be done in main.any?

I also have the problem that NoAnalogSamplesPer3DFrame is zero. The Butterworth Filter doesn’t work. Can this be changed?

Thanks in advance.

Regards

Rena

Hi Rena,

I think you can take the Butterworth filter out since it is only a filter for the analog, i.e. force data, which you don’t have in your c3d. Outcomment the Butterworth filter and set the AnalogFilterIndex in the same file to 0.

About the force: in the file Times.any, tStart and tEnd are determined using the start and end frame. I would suggest to calculate the start and end of the force in a similar way and define a Force you apply to the hand or whatever segment you like. This could e.g. look like

    AnyFunSquareWave ForceSwitch = 
    {
      InitialValues = {0.0};
      Ts = {117/....ModelSetup.C3DFileData.Header.VideoFrameRate , 456/....ModelSetup.C3DFileData.Header.VideoFrameRate};
      
      Values = {{1.0,0.0}};
      dT = {0.1,0.1};
    };
    
    AnyForce3D ForceLeftHand = 
    {
      F = {0, -100, 0} * .ForceSwitch(Main.Studies.InverseDynamicStudy.t)[0];
      //Flocal = {0, 0, 0};
      AnyRefFrame &r1 = Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.GloveInsertationNode;

    };

for a force that is simply but into the BodyModel folder of the Mocap model from the AMMR.

It doesn’t really matter where you define the forces, you can e.g. define it in the environment.

Best regards
Daniel

Hi Daniel,

Thank you for helping me.
I have now inserted the forces.
However, I would like to represent the vector only at the appropriate time (2.34 to 9.12).

A second problem is that the following error message occurs while RunMotionAndParameterOptimizationSequence:

ERROR (OBJ.MCH.KIN3): D :confused: A…n/A…o/A…n/E…s/H…3/M…l/Kinematics.any (74): Motion Optimization . Kinematics: Kinematic analysis failed in time step 237
I already passed this operation with the same settings and there was not a mistake.

I have my model appended.

About further assistance I would be very happy.

Thank you in advance.

Rena

Hi Rena,

I started the MotionAndParameterOptimization of your model, and it worked fine for me. Just the head looks a bit strange. Which AMMR are you using?

About the drawing of the force vectors. I discussed a similar problem here http://forum.anyscript.org/showthread.php?t=3474. The trick is to use an iffun for the Visibility setting of the drawing object, so the AnyDrawVector in your case. You can either set it by using the time or directly the indicator function you used for the force calculation.

Best regards
Daniel

Hi Daniel,

I’m using AMMR 1.6.2.
How can I get a normal position of my head?

I will have a look at at the thread.

Thank you for the link.

Rena

Hi Rena,

I was more wondering about the shape of the head than the position. But that is just the scaling of the head.
I still don’t have problems running your model with the latest AMMR. If it doesn’t work for you, let me know.

Best regards
Daniel

Hi Daniel,

I will change the scaling of the head.

I also tried the function for drawing the vector.
Thank you for the hint iffun. It runs fine.

Rena

Hi Daniel,

I have run the InverseDynamicStudy of my MoCapModel. I know, I have only results for upper extremities, but there are the some warnings and an error:

WARNING(OBJ.MCH.KIN7) : D:/AnyBo…Daten/A…o/Body/A…n/Arm/Muscle.any(2618) : Flexor_Pollicis_Longus.SPLine : Penetration of surface : cyl : Via-point ‘Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.Seg.Radius.Via_Flexor_Pollicis_Longus’ on ‘Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.Mus.Flexor_Pollicis_Longus.SPLine’ is located below the wrapping surface 'Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.Seg.Hand.Ref.FlexorMuscleCyl.cyl
WARNING(OBJ.MCH.KIN7) : D:/AnyBo…Daten/A…o/Body/A…n/Arm/Muscle.any(2472) : Flexor_Digitorum_Profundus__Digit4.SPLine : Penetration of surface : cyl : Via-point ‘Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.Seg.Radius.Via_Flexor_Digitorum_Profundus_Digit4’ on ‘Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.Mus.Flexor_Digitorum_Profundus__Digit4.SPLine’ is located below the wrapping surface 'Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.Seg.Hand.Ref.FlexorMuscleCyl.cyl
WARNING(OBJ.MCH.KIN7) : D:/AnyBo…Daten/A…o/Body/A…n/Arm/Muscle.any(2455) : Flexor_Digitorum_Produndus__Digit5.SPLine : Penetration of surface : cyl : Via-point ‘Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.Seg.Radius.Via_Flexor_Digitorum_Profundus_Digit5’ on ‘Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.Mus.Flexor_Digitorum_Produndus__Digit5.SPLine’ is located below the wrapping surface 'Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.Seg.Hand.Ref.FlexorMuscleCyl.cyl
WARNING(OBJ1) : D:/AnyBo…Daten/A…o/Body/A…n/Arm/Muscle.any(1148) : trapezius_scapular_part_3.SPLine : Number of allowed iterations for contact solution has been exceeded in Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.Mus.trapezius_scapular_part_3.SPLine. Final error at time 4.045944e+000: 2.543433e-007 rel error, 2.135110e-006 abs error
WARNING(OBJ1) : D:/AnyBo…Daten/A…o/Body/A…n/Arm/Muscle.any(1049) : teres_minor_1.SPLine : Number of allowed iterations for contact solution has been exceeded in Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.Mus.teres_minor_1.SPLine. Final error at time 7.092668e+000: 1.056167e-008 rel error, 1.562874e-008 abs error
WARNING(OBJ1) : D:/AnyBo…Daten/A…o/Body/A…n/Arm/Muscle.any(1049) : teres_minor_1.SPLine : Number of allowed iterations for contact solution has been exceeded in Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.Mus.teres_minor_1.SPLine. Final error at time 7.112581e+000: 1.259617e-006 rel error, 3.376772e-006 abs error
WARNING(OBJ1) : D:/AnyBo…Daten/A…o/Body/A…n/Arm/Muscle.any(1061) : teres_minor_2.SPLine : Number of allowed iterations for contact solution has been exceeded in Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.Mus.teres_minor_2.SPLine. Final error at time 7.112581e+000: 2.971793e-007 rel error, 3.863216e-007 abs error
WARNING(OBJ1) : D:/AnyBo…Daten/A…o/Body/A…n/Arm/Muscle.any(1073) : teres_minor_3.SPLine : Number of allowed iterations for contact solution has been exceeded in Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.Mus.teres_minor_3.SPLine. Final error at time 7.112581e+000: 2.122478e-005 rel error, 3.229588e-005 abs error
ERROR(OBJ1) : D:/AnyBo…Daten/A…o/Body/A…n/Arm/Muscle.any(1073) : teres_minor_3.SPLine : Factorization of stiffness matrix for velecity analysis failed. Try to use a use a larger AugLagCoef value.

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

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

Do you have a solution?
I’ve attached some pictures. Do you think the muscle stress is correct?

Thank you for your help.

Rena

Hi Rena,

it looks as you are running into problems with the muscle wrapping. For debugging I would suggest that you look at the muscles mentioned to look if they are switching sides of the wrapping surfaces. Therefore, you could switch on the drawing of these surfaces or add draw objects if they are not already in the code.
If it is the case that the wrapping behaves strangely, I would recommend to add more constraints to it to make it behave nicely.

Best regards,
Daniel

Hi Daniel,

do you have more information about that?
I do not really know what you mean.

Thanks in advance.

Rena

Hi Rena,

if you e.g. take the last error message, there is a muscle teres_minor_3 mentioned. If you look at the definition of the muscle, you can see that the muscle has at least one wrapping surface. If you go to the definition of that surface, you either switch on a drawing object that might be implemented but out-commented in AnyScript, or you have to define a drawing object AnyDrawSurfacefor this surface. Typically, the muscle should stay on one side of the surface, but sometimes it can flip to the other side for some reason. The first thing is therefore to check that this is not the case.

Have you looked at the AnyBody youtube channel? There is a nice, short tutorial about navigating in AMS, http://www.youtube.com/watch?v=MQsUUdoKsGg&list=TLSahgvlx6QxkTXSrO3bE0NVJAABmDKv88.
This will probably help you find the muscle and the wrapping surface for it.

I hope this short description helps a bit for solving your problem.

Best regards
Daniel

Hi Daniel,

could you please help me again?

When I start the RunMotionAndParameterOptimizationSequence there is the following Error Message like on Monday and I don’t know why.

You said that you don’t have problems with my model.
I attached my model again.

  1. RunMotionAndParameterOptimizationSequence (Operation: Main.RunMotionAndParameterOptimizationSequence):

Macro command : RunMotionAndParameterOptimizationSequence(1:5)> operation Main.Studies.ParameterIdentification.ParameterOptimization

Macro command : RunMotionAndParameterOptimizationSequence(2:5)> run

2.0.0) Operation Sequence: (Operation: Main.Studies.ParameterIdentification.Analysis):
2.0.0.0) Kinematics (Operation: Main.Studies.KinematicStudyForParameterIdentification.Kinematics):
2.0.0.0.0) PreOperation (Operation: Main.Studies.KinematicStudyForParameterIdentification.Kinematics.PreOperation):
2.0.0.0.0.0) InitialConditions (Operation: Main.Studies.KinematicStudyForParameterIdentification.InitialConditions):
2.0.0.0.0.0) …Design variables have been updated.
2.0.0.0.0.1) …Load-time positions have been re-established.
2.0.0.0.0.2) …Kinematic analysis completed. The kinematic constraints have been resolved.
2.0.0.0.0.3) …Initial conditions are fully updated.
2.0.0.0) Kinematic analysis…
WARNING(OBJ.MCH.KIN6) : D:/AnyB…ten/A…o/Body/A…n/Arm/Interface.any(82) : GHMeasure : Close to singular position : Orientation close to Gimbal Lock, i.e., first and third axis of rotation being parallel
2.0.0.76) …Kinematic analysis completed
2.0) Optimization (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Optimization step (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Evaluating KKT conditions (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Evaluating the objective function (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Calculating a new search direction (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Optimization step (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Evaluating KKT conditions (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Evaluating the objective function (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Calculating a new search direction (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Optimization step (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Evaluating KKT conditions (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Evaluating the objective function (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Calculating a new search direction (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Optimization step (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Evaluating KKT conditions (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Evaluating the objective function (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Calculating a new search direction (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Optimization step (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Evaluating KKT conditions (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
2.0) Evaluating the objective function (Operation: Main.Studies.ParameterIdentification.ParameterOptimization):
Optimization converged

Macro command : RunMotionAndParameterOptimizationSequence(3:5)> classoperation Main.Studies.ParameterIdentification “Save design” --file="…/Input/FullBody-kF_BS65a-OptimizedParameters.txt"

Main.Studies.ParameterIdentification : Saving design…

Macro command : RunMotionAndParameterOptimizationSequence(4:5)> operation Main.Studies.MotionOptimization.Kinematics

Macro command : RunMotionAndParameterOptimizationSequence(5:5)> run

5.0) Kinematics (Operation: Main.Studies.MotionOptimization.Kinematics):
5.0.0) PreOperation (Operation: Main.Studies.MotionOptimization.Kinematics.PreOperation):
5.0.0.0) InitialConditions (Operation: Main.Studies.MotionOptimization.InitialConditions):
5.0.0.0) …Design variables have been updated.
5.0.0.1) …Load-time positions have been re-established.
5.0.0.2) …Kinematic analysis completed. The kinematic constraints have been resolved.
5.0.0.3) …Initial conditions are fully updated.
5.0) Kinematic analysis…
WARNING(OBJ.MCH.KIN6) : D:/AnyB…ten/A…o/Body/A…n/Arm/Interface.any(82) : GHMeasure : Close to singular position : Orientation close to Gimbal Lock, i.e., first and third axis of rotation being parallel
Failed to resolve kinematic constraints. Newton relaxation too small. (final kin. error = 1.333561E-004)
Constraint no. 11 above error tolerance 0.000001, error = 0.000003.
Constraint no. 12 above error tolerance 0.000001, error = 0.000002.
Constraint no. 13 above error tolerance 0.000001, error = 0.000005.
Constraint no. 14 above error tolerance 0.000001, error = 0.000017.
Constraint no. 15 above error tolerance 0.000001, error = 0.000006.
Constraint no. 16 above error tolerance 0.000001, error = 0.000004.
Constraint no. 17 above error tolerance 0.000001, error = 0.000038.
Constraint no. 18 above error tolerance 0.000001, error = 0.000015.
Constraint no. 19 above error tolerance 0.000001, error = 0.000080.
Constraint no. 20 above error tolerance 0.000001, error = 0.000073.
Constraint no. 21 above error tolerance 0.000001, error = 0.000005.
Constraint no. 22 above error tolerance 0.000001, error = 0.000002.
Constraint no. 28 above error tolerance 0.000001, error = 0.000018.
Constraint no. 29 above error tolerance 0.000001, error = 0.000009.
Constraint no. 30 above error tolerance 0.000001, error = 0.000004.
Constraint no. 34 above error tolerance 0.000001, error = 0.000002.
Constraint no. 35 above error tolerance 0.000001, error = 0.000034.
Constraint no. 36 above error tolerance 0.000001, error = 0.000015.
Constraint no. 37 above error tolerance 0.000001, error = 0.000007.
Constraint no. 41 above error tolerance 0.000001, error = 0.000003.
Constraint no. 42 above error tolerance 0.000001, error = 0.000051.
Constraint no. 43 above error tolerance 0.000001, error = 0.000021.
Constraint no. 44 above error tolerance 0.000001, error = 0.000009.
Constraint no. 47 above error tolerance 0.000001, error = 0.000003.
Constraint no. 48 above error tolerance 0.000001, error = 0.000006.
Constraint no. 49 above error tolerance 0.000001, error = 0.000067.
Constraint no. 50 above error tolerance 0.000001, error = 0.000025.
Constraint no. 51 above error tolerance 0.000001, error = 0.000011.
Constraint no. 54 above error tolerance 0.000001, error = 0.000008.
Constraint no. 55 above error tolerance 0.000001, error = 0.000009.

Constraint no. 558 above error tolerance 0.000001, error = 0.000002.
Constraint no. 560 above error tolerance 0.000001, error = 0.000001.
Constraint no. 561 above error tolerance 0.000001, error = 0.000001.
Constraint no. #4 in ‘Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.Jnt.WristJointFlexion.Constraints’ above error tolerance 0.000001, error = 0.000002.
Constraint no. #3 in ‘Main.Studies.HumanModel.BodyModel.Right.ShoulderArm.Jnt.WristJointDeviation.Constraints’ above error tolerance 0.000001, error = 0.000002.
Constraint no. #0 in ‘Main.Studies.HumanModel.BodyModel.Left.Leg.Jnt.Ankle.Constraints’ above error tolerance 0.000001, error = 0.000001.
Constraint no. #1 in ‘Main.Studies.HumanModel.BodyModel.Left.Leg.Jnt.Ankle.Constraints’ above error tolerance 0.000001, error = 0.000001.
Constraint no. #2 in ‘Main.Studies.HumanModel.BodyModel.Left.Leg.Jnt.Ankle.Constraints’ above error tolerance 0.000001, error = 0.000001.
Constraint no. #0 in ‘Main.Studies.HumanModel.BodyModel.Left.Leg.Jnt.SubTalar.Constraints’ above error tolerance 0.000001, error = 0.000001.
Constraint no. #1 in ‘Main.Studies.HumanModel.BodyModel.Left.Leg.Jnt.SubTalar.Constraints’ above error tolerance 0.000001, error = 0.000001.
5.237) …Kinematic analysis terminated
ERROR(OBJ.MCH.KIN3) : D:/A…n/A…o/A…n/E…s/H…S/M…l/Kinematics.any(74) : MotionOptimization.Kinematics : Kinematic analysis failed in time step 237

Many thanks!!

Verena

Hi Verena,

unfortunately I cannot open the zip file you uploaded. Could you check if it works for you and maybe change it to some other format or fix it?

Regards,
Daniel

Now, it must be possible.

Now it must be possible.

Rena

Now it must be possible.

Rena

Hi Daniel,

could I send you an email?
I don’t know why you can’t download the file.

Regards.

Rena