Skip to content

Commit

Permalink
feat: Ammr test upd (#42)
Browse files Browse the repository at this point in the history
* 2par iteration 2

* add neutral angles

* refactor positions matrices to be pointers and allow users to open in tree.
add warning when npos does not match nstep

* add abduction pos

* refactor studies to avoid lower leg calibration errors

* expand RoM studies for new cal method

* fix wrong conditional logic

* start new test subfolders

* move deltoid test

* move gui template tests

* move thoracic tests

* move abdominal test

* refactor passive flexible test

* refactor kinematic test

* fix missing libdef files

* mock new data structure in TLEM leg model

* lower hip flexion RoM to avoid RecFem penetration

* add main folder to empty test files

* lower hip flexion to avoid recfem penetration in old cal routine

* use local density as other segs

* fix failing loads

* fix path in moved tests

* add strength test

* fix missing file

* fix double include

* update leg cal interface to range of motion data

* add range of motion def to trunk

* add arm range of motion def

* fix conditional logic

* fic conditonals around calibration

* add trunk cal test

* upd existing cal study to run w. felx thorac

* implement 3e mus mdls for spline defined trunk muscles

* add known failures

* change to ignore instead of known-failure

* remove 3e models from ribcage muscles

* adjust test files failing on warnings

* convert pelvis-sacrum and ribcage muscles to simple muscle models

* exclude pelvic floor muscles from calibration

* change to Pm test in each RoM study

* only ignore lower_body tests

* fix missing quotes in .ini file

* fix ignore path relative to test folder
  • Loading branch information
bkje14 authored Jan 31, 2025
1 parent d72f2a6 commit 575d49f
Show file tree
Hide file tree
Showing 72 changed files with 5,268 additions and 5,671 deletions.
2 changes: 1 addition & 1 deletion Body/AAUHuman/Arm/ArmData1.1/ArmModelMuscleParameters.any
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
#define _TENDON_LENGTH_DESIGNVAR(x) (x)
#define _FIBER_LENGTH_DESIGNVAR(x) DesignVar(x)
#endif
#if BM_CALIBRATION_TYPE == _CALIBRATION_TYPE_2PAR_
#if (BM_CALIBRATION_TYPE == _CALIBRATION_TYPE_2PAR_) | (BM_CALIBRATION_TYPE == _EXPERIMENTAL_CALIBRATION_TYPE_2PAR_)
#define _TENDON_LENGTH_DESIGNVAR(x) (x)
#define _FIBER_LENGTH_DESIGNVAR(x) (x)
#endif
Expand Down
16 changes: 12 additions & 4 deletions Body/AAUHuman/Arm/ShoulderArmModel.root.any
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,24 @@ AnyDoc ArmDoc ={
#path BM_ARM_DATASET_PATH "../ARM/"+BM_ARM_DATASET
#endif

AnyFolder Data = {
AnyFolder unscaled = {
AnyFolder &ModelParameters = ..ModelParameters;
AnyFolder STL = {#include "<BM_ARM_DATASET_PATH>/STL/STL.any"};
AnyFolder StandardParameters = {
#include "..\BodyModels\Include\BodyParameters.any"
#include "StandardParameters.any"
};
};
#include "rangeOfMotion.any"
};

AnyFolder ModelParameters = {
#include "<BM_ARM_DATASET_PATH>/ArmModelParameters.any"
#include "<BM_ARM_DATASET_PATH>/ArmModelMuscleParameters.any"
};

AnyFolder STL = {
#include "<BM_ARM_DATASET_PATH>/STL/STL.any"
};

AnyFolder &STL = Data.unscaled.STL;

#include "ScapulaContactElipsoid.any"
AnyFolder MuscleModels = {};
Expand Down
30 changes: 30 additions & 0 deletions Body/AAUHuman/Arm/rangeOfMotion.any
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Range of Motion definition for the Arm */

AnyFolder RangeOfMotion = {
AnyFolder Shoulder = {
AnyVar MaxGlenohumeralFlexionAngle = 160;
AnyVar MaxGlenohumeralExtensionAngle = -70;
AnyVar MaxGlenohumeralAbductionAngle = 178;
AnyVar MaxGlenohumeralAdductionAngle = -44;
AnyVar MaxGlenohumeralExternalRotationAngle = 89;
AnyVar MaxGlenohumeralInternalRotationAngle = 89;
AnyVar MaxScapulaClaviculaElevationAngle = 40;
AnyVar MaxScapulaClaviculaDepressionAngle = -5;
AnyVar MaxScapulaClaviculaProtractionAngle = 15;
AnyVar MaxScapulaClaviculaRetractionAngle = -36;
};

AnyFolder Elbow = {
AnyVar MaxFlexionAngle = 150;
AnyVar MaxExtensionAngle = 0;
AnyVar MaxPronationAngle = 90;
AnyVar MaxSupinationAngle = -90;
};

AnyFolder Wrist = {
AnyVar MaxFlexionAngle = 85;
AnyVar MaxExtensionAngle = -70;
AnyVar MaxAbductionAngle = 20;
AnyVar MaxAdductionAngle = -35;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
//
// Muscle Calibration related logic
//
#if BM_CALIBRATION_TYPE == _CALIBRATION_TYPE_2PAR_ & BM_TRUNK_CERVICAL_RHYTHM == OFF
#if ((BM_CALIBRATION_TYPE == _CALIBRATION_TYPE_2PAR_) | (BM_CALIBRATION_TYPE == _EXPERIMENTAL_CALIBRATION_TYPE_2PAR_)) & BM_TRUNK_CERVICAL_RHYTHM == OFF

AnyInt bm_cervical_rhythm_notice1= notice(0, strformat("\n"+
"------------------------------------------------------------------------------------------------------\n"+
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
Class Template for providing the folder structure of the body model
*/
#class_template BodyModelFolderStructure() {
AnyFolder Trunk = {
};
AnyFolder Right = {
AnyFolder ShoulderArm = {
AnyFolder Shoulder = {};
AnyFolder Elbow = {};
AnyFolder Wrist = {};
};
AnyFolder Leg = {
AnyFolder Hip = {};
AnyFolder Knee = {};
AnyFolder Ankle = {};
AnyFolder SubTalar = {};
};
};
AnyFolder Left = {
AnyFolder ShoulderArm = {
AnyFolder Shoulder = {};
AnyFolder Elbow = {};
AnyFolder Wrist = {};
};
AnyFolder Leg = {
AnyFolder Hip = {};
AnyFolder Knee = {};
AnyFolder Ankle = {};
AnyFolder SubTalar = {};
};
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@

#define _CALIBRATION_TYPE_2PAR_ 2

#define _EXPERIMENTAL_CALIBRATION_TYPE_2PAR_ 3

#define _CALIBRATION_TYPE_CUSTOM_ 0

#define CONST_MUSCLES_NONE 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,22 @@
"------------------------------------------------------------------------------------------------------------------------ "));
#endif


#ifdef BM_CALIBRATION_TYPE
#if BM_CALIBRATION_TYPE == _EXPERIMENTAL_CALIBRATION_TYPE_2PAR_
#ifdef BM_LEG_MODEL
#if BM_LEG_MODEL == _LEG_MODEL_TLEM1_
AnyInt not_implemented_calibration_for_TLEM1 = warn(0, strformat("\n"+
"------------------------------------------------------------------------------------------------------\n"+
" The Experimental 2-parameter calibration routine (BM_CALIBRATION_TYPE == _EXPERIMENTAL_CALIBRATION_TYPE_2PAR_ \n"+
" is not compatible with The Twente Lower Extremity Model v.1 (TLEM1). \n"+
" Please use the TLEM 2 (which is default or set: #define BM_LEG_MODEL _LEG_MODEL_TLEM2_) \n"+
"-------------------------------------------------------------------------------------------------------"));
#endif
#endif
#endif
#endif

#ifndef ANYBODY_PYTHON_SUPPRESS_NOTICE
#if ANYBODY_PYTHON_AVAILABLE == 0
AnyMessage PythonMissing =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/**
Class template for creating a model that can be used to calibrate the legs
*/
#class_template LegCalibrationModel(Side, BodyModelRef) {
AnyComponentDefinition CDef = {};

#var AnyObjectPtr HipPositions;
#var AnyObjectPtr KneePositions;
#var AnyObjectPtr AnklePositions;
#var AnyObjectPtr SubTalarPositions;

AnyFolder &Pelvis = BodyModelRef.Trunk.Segments.PelvisSeg;
AnyFolder &Sacrum = BodyModelRef.Trunk.Segments.SacrumSeg;
AnyFolder &Thorax = BodyModelRef.Trunk.Segments.ThoraxSeg;

AnySeg &L1 = BodyModelRef.Trunk.Segments.L1Seg;
AnySeg &L2 = BodyModelRef.Trunk.Segments.L2Seg;
AnySeg &L3 = BodyModelRef.Trunk.Segments.L3Seg;
AnySeg &L4 = BodyModelRef.Trunk.Segments.L4Seg;
AnySeg &L5 = BodyModelRef.Trunk.Segments.L5Seg;

AnyFolder &LumbarJoints = BodyModelRef.Trunk.Joints.Lumbar;

AnyFolder &LegSegments = BodyModelRef.Side.Leg.Seg;
AnyFolder &LegJoints = BodyModelRef.Side.Leg.Jnt;

AnyFolder &Muscles = BodyModelRef.Side.Leg.Mus;

// Constraints
AnyFixedRefFrame ground = {
AnyRefNode node = {
ARel = ..Pelvis.Axes0;
sRel = ..Pelvis.r0;
};
};

AnyKinEq ThoraxFix = {
AnyKinMeasure& PelvisThoraxExtension = BodyModelRef.Interface.Trunk.PelvisThoraxExtension;
AnyKinMeasure& PelvisThoraxLateralBending = BodyModelRef.Interface.Trunk.PelvisThoraxLateralBending;
AnyKinMeasure& PelvisThoraxRotation = BodyModelRef.Interface.Trunk.PelvisThoraxRotation;
};

AnyKinEq PelvisFix = {
AnyKinLinear Lin = {
AnyRefFrame &ground = ..ground.node;
AnyRefFrame &Pelvis = ..Pelvis;
};
AnyKinRotational Rot = {
Type = RotAxesAngles;
AnyRefFrame &ground = ..ground.node;
AnyRefFrame &Pelvis = ..Pelvis;
};
};

AnyKinEqInterPolDriver Hip = {
AnyKinRotational &Spherical = .BodyModelRef.Interface.Side.HipFlexion.HipMeasure;
Type = PiecewiseLinear;
T = linspace(0,1,SizesOf(Data)[1]);
Data = Obj2Num(.HipPositions)' * pi/180;
Reaction.Type = {Off, Off, Off};
AnyInt expect_nPos_to_match_nStep = warn(eqfun(NumElemOf(T), ..nStep), strformat("The number of calibration positions (Data) in the: " + NameOf(ObjGetParent(0)) + " driver does not match the number of positions (nStep) in the study."));

};

AnyKinEqInterPolDriver Knee = {
AnyKinMeasure& Hinge = .BodyModelRef.Interface.Side.KneeFlexion;
Type = PiecewiseLinear;
T = linspace(0,1,SizesOf(Data)[1]);
Data = {Obj2Num(.KneePositions)} * pi/180;
Reaction.Type = {Off};
AnyInt expect_nPos_to_match_nStep = warn(eqfun(NumElemOf(T), ..nStep), strformat("The number of calibration positions (Data) in the: " + NameOf(ObjGetParent(0)) + " driver does not match the number of positions (nStep) in the study."));

};

AnyKinEqInterPolDriver Ankle = {
AnyKinMeasure& Hinge = .BodyModelRef.Interface.Side.AnklePlantarFlexion;
Type = PiecewiseLinear;
T = linspace(0,1,SizesOf(Data)[1]);
Data = {Obj2Num(.AnklePositions)} * pi/180;
Reaction.Type = {Off};
AnyInt expect_nPos_to_match_nStep = warn(eqfun(NumElemOf(T), ..nStep), strformat("The number of calibration positions (Data) in the: " + NameOf(ObjGetParent(0)) + " driver does not match the number of positions (nStep) in the study."));

};

AnyKinEqInterPolDriver SubTalar = {
AnyKinMeasure& Hinge = .BodyModelRef.Interface.Side.SubTalarEversion;
Type = PiecewiseLinear;
T = linspace(0,1,SizesOf(Data)[1]);
Data = {Obj2Num(.SubTalarPositions)} * pi/180;
Reaction.Type = {Off};
AnyInt expect_nPos_to_match_nStep = warn(eqfun(NumElemOf(T), ..nStep), strformat("The number of calibration positions (Data) in the: " + NameOf(ObjGetParent(0)) + " driver does not match the number of positions (nStep) in the study."));

};
};


/**
Class template for creating calibrationstudies with same settings
*/
#class_template LegCalibrationStudy(
__CLASS__ = AnyBodyCalibrationStudy,
BodyModelRef,
Side,
) {
// Study settings
FiberAndTendonLengthAdjustment.CalibrateTendonAtMaxForceOnOff = Off;
Kinematics.SmallStepAssumptionOnOff = Off;
InitialConditions.SmallStepAssumptionOnOff = Off;
Kinematics.PosAnalysisOnlyOnOff = On;
InitialConditions.PosAnalysisOnlyOnOff = On;

LegCalibrationModel ModelRef(Side=Side, BodyModelRef=BodyModelRef) = {
HipPositions = .HipPositions;
KneePositions = .KneePositions;
AnklePositions = .AnklePositions;
SubTalarPositions = .SubTalarPositions;
};
};

12 changes: 12 additions & 0 deletions Body/AAUHuman/BodyModels/GenericBodyModel/Calibration/RValues.any
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
Folder containing different R values (ratios of muscle fiber length to optimal fiber
length) for different purposes.
*/
AnyFolder RValues = {
AnyFloat RMinNoMuscleForce = 0.5;
AnyFloat RMinDefault = 0.6;

AnyFloat RMaxDefault = 1.2;
AnyFloat RMaxActiveStretching = 1.3;
AnyFloat RMaxPassiveForceEqualToFMax = 1.5;
};
Loading

0 comments on commit 575d49f

Please sign in to comment.