|
a |
|
b/Tools/AnyMocap/InterpolateJointAngleData.any |
|
|
1 |
#ifndef MOCAP_FILTER_JOINT_ANGLES |
|
|
2 |
#define MOCAP_FILTER_JOINT_ANGLES OFF |
|
|
3 |
#endif |
|
|
4 |
|
|
|
5 |
#ifndef _MOCAP_FULL_TARRAY |
|
|
6 |
#define _MOCAP_FULL_TARRAY Main.Studies.MarkerTracking.tArray |
|
|
7 |
#endif |
|
|
8 |
|
|
|
9 |
#ifndef _MOCAP_MAIN_STUDY_REF |
|
|
10 |
#define _MOCAP_MAIN_STUDY_REF Main.Studies.InverseDynamicStudy |
|
|
11 |
#endif |
|
|
12 |
|
|
|
13 |
AnyFunInterpol InterpolatedData = |
|
|
14 |
{ |
|
|
15 |
Type ??= iffun(gtfun(.FileReader.Length0, 1), Bspline, ConstantValue); |
|
|
16 |
BsplineOrder ??= min({4,.FileReader.Length0}); |
|
|
17 |
T = .FileReader.T; |
|
|
18 |
|
|
|
19 |
#if MOCAP_FILTER_JOINT_ANGLES == ON |
|
|
20 |
Data = Main.ModelSetup.JointAngleFilter.FilterFun(.FileReader.Data); |
|
|
21 |
#else |
|
|
22 |
Data ??= .FileReader.Data; |
|
|
23 |
#endif |
|
|
24 |
}; |
|
|
25 |
|
|
|
26 |
AnyInputFile FileReader = { |
|
|
27 |
// Check if the start time is with the range of data in the file. |
|
|
28 |
|
|
|
29 |
/// Number of data elements in the file |
|
|
30 |
AnyInt nFile = NumElemOf(.FileReader.TFile); |
|
|
31 |
|
|
|
32 |
AnyFloat TFileMin = arrcat(TFile, {0.0})[0]; |
|
|
33 |
AnyFloat TFileMax = arrcat(TFile, {0.0})[ max({ min({TFileNumRead,Length0})-1,0})]; |
|
|
34 |
AnyInt ValidStartTime = andfun( gtfun(_MOCAP_MAIN_STUDY_REF.tArray[0],TFileMin-1e-13), |
|
|
35 |
ltfun(_MOCAP_MAIN_STUDY_REF.tArray[0], TFileMax+1e-13)); |
|
|
36 |
|
|
|
37 |
|
|
|
38 |
AnyInt ValidData = andfun(ValidStartTime, bool(TFileIsMonotoneIncreasing)); |
|
|
39 |
|
|
|
40 |
// If there is problems with the file data, force the use of default data. |
|
|
41 |
AlwaysUseData0 ??= not(ValidData); |
|
|
42 |
|
|
|
43 |
// FileName: This is set externally to this include file. |
|
|
44 |
FileErrorContinueOnOff = On; |
|
|
45 |
ReloadOnOff = On; |
|
|
46 |
SuppressWarningsOnOff = On; |
|
|
47 |
|
|
|
48 |
AnyInt Length0 = NumElemOf(_MOCAP_FULL_TARRAY); |
|
|
49 |
T0 = _MOCAP_FULL_TARRAY; |
|
|
50 |
}; |
|
|
51 |
|
|
|
52 |
#ifndef _ANYMOCAP_JOINT_ANGLE_WARNING_MSG_ |
|
|
53 |
#define _ANYMOCAP_JOINT_ANGLE_WARNING_MSG_ |
|
|
54 |
AnyMessage AnyMoCap_msg1= |
|
|
55 |
{ |
|
|
56 |
AnyInt LastTimeIdx = max({0,.FileReader.TFileNumRead-1}); |
|
|
57 |
AnyVar LastTimeInFile = .FileReader.T[min({LastTimeIdx, NumElemOf(.FileReader.T)-1})]; |
|
|
58 |
TriggerRuntime = andfun(.FileReader.ValidData, |
|
|
59 |
andfun(_MOCAP_MAIN_STUDY_REF.iStep, gtfun(_MOCAP_MAIN_STUDY_REF.t, LastTimeInFile ))); |
|
|
60 |
Type = MSG_ErrorFatal; |
|
|
61 |
Message = DesignVar(strformat("\n"+ |
|
|
62 |
"----------------------------------------------------------------------------------------------------------\n"+ |
|
|
63 |
" No kinematic joint angle data available after t = "+strval(LastTimeInFile, "%.3g") + "s.\n "+ |
|
|
64 |
" Please re-run the entire Marker Tracking first (or Main.RunAnalysis)\n"+ |
|
|
65 |
"----------------------------------------------------------------------------------------------------------\n")); |
|
|
66 |
}; |
|
|
67 |
AnyMessage AnyMoCap_msg2= |
|
|
68 |
{ |
|
|
69 |
TriggerRuntime = andfun(eqfun(_MOCAP_MAIN_STUDY_REF.iStep,1), not(.FileReader.ValidData)); |
|
|
70 |
Type = MSG_ErrorFatal; |
|
|
71 |
Message = DesignVar(strformat("\n"+ |
|
|
72 |
"----------------------------------------------------------------------------------------------------------\n"+ |
|
|
73 |
" No valid kinematic joint angle data available.\n"+ |
|
|
74 |
" Please run the Marker Tracking analysis first (or Main.RunAnalysis)\n"+ |
|
|
75 |
"----------------------------------------------------------------------------------------------------------\n")); |
|
|
76 |
}; |
|
|
77 |
#endif |