|
a |
|
b/Application/Examples/StandingPosturePredictionWithLoad/StandingPosturePrediction.main.any |
|
|
1 |
//This is a model which can predict the posture as a consequence of applied loads in hands. |
|
|
2 |
//It does this by minimizing joint torques and apply balance drivers which account for external |
|
|
3 |
//applied loads. |
|
|
4 |
// |
|
|
5 |
// |
|
|
6 |
//The model is driven by a combination of the following drivers: |
|
|
7 |
// * Drivers which minimize the joint moments (arising from gravity and applied loads in hands) in elbow, shoulder, L4L5 and knee |
|
|
8 |
// * Driver which tries to keep the CoP inside the foot stance area. |
|
|
9 |
// * Feet maintain contact with the ground, but the position can be controlled by widgets |
|
|
10 |
// * Hands are linked to an object, of which positioning can be altered using widgets |
|
|
11 |
// |
|
|
12 |
//Two type of loads can be applied, either a fixed weight of the object and/or a force vector |
|
|
13 |
// |
|
|
14 |
//The current model has a force vector applied on the object being held between the hands with a zero weight of the object (this is editable) |
|
|
15 |
// |
|
|
16 |
// |
|
|
17 |
//To run the model |
|
|
18 |
// * Load the model |
|
|
19 |
// * Try to drag (click and drag) one of the widgets in the ModelView (seen as small coordinate systems) |
|
|
20 |
// * When the widget is release the model will run the analysis |
|
|
21 |
|
|
|
22 |
#include "libdef.any" |
|
|
23 |
|
|
|
24 |
#include "jointlimit/Balance_template_foot_area.any" |
|
|
25 |
#include "MinTorqueClass/MinTorqueClass.any" |
|
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
//Switch to define if load is applied to both hands or a single hand. |
|
|
30 |
//Three combinations LoadInRightHand,LoadInLeftHand,LoadInRightHand+LoadInLeftHand |
|
|
31 |
#define LoadInRightHand 1 |
|
|
32 |
#define LoadInLeftHand 1 |
|
|
33 |
#include "<ANYBODY_PATH_MODELUTILS>/Video/VideoLookAtCamera.any" |
|
|
34 |
|
|
|
35 |
|
|
|
36 |
Main = { |
|
|
37 |
|
|
|
38 |
#include "Model/BodyModelConfig.any" |
|
|
39 |
|
|
|
40 |
// Using your own Mannequin.any file in the Model folder of your model |
|
|
41 |
#include "Model\Mannequin.any" |
|
|
42 |
|
|
|
43 |
// Include default human model |
|
|
44 |
#include "<ANYBODY_PATH_BODY>\HumanModel.any" |
|
|
45 |
|
|
|
46 |
AnyFolder InputParameters ={ |
|
|
47 |
|
|
|
48 |
//Model can be loaded with both a force and a weight of an object |
|
|
49 |
AnyVec3 ForceDirection = DesignVar({0,0.01,-1}); // this is the initial direction of the force it can be manipulated by widget (vertical blue line upon load) |
|
|
50 |
AnyVar ForceMagnitude = 100; //this is the initial value of the force it can be manipulated by dragging the widget |
|
|
51 |
|
|
|
52 |
//Initial value of handforce as a function of time, each element has corresponding timevar in HandForceTime |
|
|
53 |
//These lines should generally not be changed, they are generic and made using ForceMagnitude and ForceDirection |
|
|
54 |
AnyFloat HandForceTime ={-10,0,1,3,4,10}; //this time vector needs to be larger than tStart-tEnd |
|
|
55 |
AnyFloat HandForce = { ForceDirection[0]*ForceMagnitude*{1,1,1,1,1,1}, ForceDirection[1]*ForceMagnitude*{1,1,1,1,1,1}, ForceDirection[2]*ForceMagnitude*{1,1,1,1,1,1}}; |
|
|
56 |
|
|
|
57 |
//weight of object and location |
|
|
58 |
AnyVar ObjectWeight = 5; //weight of mass applied |
|
|
59 |
AnyVec3 ObjectPoint = DesignVar({0.65,0,1.0}); //initial position of object, dragging the widget will change this |
|
|
60 |
AnyMat33 ObjectOrientation = RotMat(0*pi/180,x)*RotMat(0*pi/180,y)*RotMat(0*pi/180,z); //initial orientation of object |
|
|
61 |
AnyVec3 HandPosRight = {0,-0.1,0}; //position of the handle coordinates wrt CoM of Object |
|
|
62 |
AnyVec3 HandPosLeft = {0,0.1,0}; //position of the handle coordinates wrt CoM of Object |
|
|
63 |
|
|
|
64 |
AnyVec3 RightFootPoint =DesignVar({0.1,-0.1,0}); //initial position of the right foot |
|
|
65 |
AnyVec3 LeftFootPoint =DesignVar({0.5,0.1,0}); //initial position of the left foot |
|
|
66 |
|
|
|
67 |
}; |
|
|
68 |
|
|
|
69 |
AnyFolder Model = { |
|
|
70 |
|
|
|
71 |
AnyFolder &InputParams=Main.InputParameters; |
|
|
72 |
|
|
|
73 |
//This file contains the balance and torque minimization drivers for the model |
|
|
74 |
#include "Posture_Motion/ExternalForceBalanceControlSimpleWithClass.any" |
|
|
75 |
|
|
|
76 |
// A link to the human model |
|
|
77 |
AnyFolder &HumanModel=.HumanModel.BodyModelWithDefaultDrivers; |
|
|
78 |
|
|
|
79 |
// Environment files are used to include objects surrounding human, e.g. global reference frame, widgets, box for visualization |
|
|
80 |
#include "Model\Environment.any" |
|
|
81 |
|
|
|
82 |
AnyFolder ModelEnvironmentConnection = { |
|
|
83 |
// This file contains all joint and foot reaction forces to simulate the standing human |
|
|
84 |
#include "Model\JointsAndDrivers.any" |
|
|
85 |
#include "Model\Force.any" |
|
|
86 |
}; |
|
|
87 |
}; |
|
|
88 |
|
|
|
89 |
//This kin study runs before the normal study with a coarser kin tolerance and some drivers exluded |
|
|
90 |
AnyBodyStudy Kinematic_Pre_Study= { |
|
|
91 |
|
|
|
92 |
AnyMechObjectExcluder ExcludeDrivers = { |
|
|
93 |
//Exclude some drivers from this study to make it kinematically safer. |
|
|
94 |
Objects = arrcat( |
|
|
95 |
ObjSearch("Main.Model.OverallWeightBalanceControl.EquilibriumEq_Driver","AnyMechObject"), |
|
|
96 |
ObjSearch("Main.Model.MinMomentOnL5SacrumJnt.EquilibriumEq_Driver","AnyMechObject") |
|
|
97 |
); |
|
|
98 |
}; |
|
|
99 |
|
|
|
100 |
AnyFolder &Model = .Model; |
|
|
101 |
|
|
|
102 |
tStart=.Study.tStart; |
|
|
103 |
tEnd=.Study.tEnd; |
|
|
104 |
|
|
|
105 |
Gravity={0.0, 0.0,-9.81}; |
|
|
106 |
nStep = 1; |
|
|
107 |
InitialConditions.MaxIteration=Kinematics.MaxIteration; |
|
|
108 |
InitialConditions.Relax=1; |
|
|
109 |
Kinematics.MaxIteration =5000; |
|
|
110 |
//Note the high tolerance |
|
|
111 |
Kinematics.KinematicTol=0.5; |
|
|
112 |
InitialConditions.KinematicTol= Kinematics.KinematicTol; |
|
|
113 |
Kinematics.SolverType = KinSolOverDeterminate; |
|
|
114 |
InitialConditions.SolverType = Kinematics.SolverType ; |
|
|
115 |
Kinematics.PosAnalysisOnlyOnOff =On; |
|
|
116 |
InitialConditions.PosAnalysisOnlyOnOff=On; |
|
|
117 |
|
|
|
118 |
InitialConditions.UseStartGuessOnOff =Off;//Setting this to OFF makes model start from last solved frame, it does not use load positions |
|
|
119 |
Kinematics.UseStartGuessOnOff =Off; |
|
|
120 |
}; |
|
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
|
124 |
AnyBodyStudy Study = { |
|
|
125 |
AnyFolder &Model = .Model; |
|
|
126 |
Gravity={0.0,0.0, -9.81}; |
|
|
127 |
nStep = 1; |
|
|
128 |
tEnd=1; |
|
|
129 |
Kinematics.SolverType = KinSolOverDeterminate; |
|
|
130 |
InitialConditions.SolverType = Kinematics.SolverType ; |
|
|
131 |
Kinematics.PosAnalysisOnlyOnOff =On; |
|
|
132 |
InitialConditions.PosAnalysisOnlyOnOff=On; |
|
|
133 |
Kinematics.MaxIteration =5000; |
|
|
134 |
Kinematics.KinematicTol=5e-6; |
|
|
135 |
|
|
|
136 |
Kinematics.SmallStepAssumptionOnOff =Off; |
|
|
137 |
|
|
|
138 |
InitialConditions.UseStartGuessOnOff =Off; //Setting this to OFF makes model start from last solved frame, it does not use load positions |
|
|
139 |
Kinematics.UseStartGuessOnOff =Off; |
|
|
140 |
|
|
|
141 |
}; |
|
|
142 |
|
|
|
143 |
AnyOperationSequence WidgetOperation = { |
|
|
144 |
|
|
|
145 |
AnyOperation &Ini=Main.Kinematic_Pre_Study.InitialConditions; |
|
|
146 |
AnyOperation &Inv=Main.Study.InverseDynamics; |
|
|
147 |
|
|
|
148 |
}; |
|
|
149 |
|
|
|
150 |
|
|
|
151 |
#include "Model\RunAppSequence.any" |
|
|
152 |
|
|
|
153 |
|
|
|
154 |
}; //Main |
|
|
155 |
|
|
|
156 |
|