
====================================
===== INVERSE DYNAMICAL MODULE =====
====================================
author: Philippe Verbist
date: 2018/05/21




The inverse dynamical module allows to compare the performances of a controller with respect to a new reference kinematics.

NB: the extension ".m" are renamed into ".msync" to sync with git. Please rename these files by ".m" if you need them.


------------------------------
Procedure for the sanity check
------------------------------

	1. In "workR/CMakeList.txt", set the parameters as following:
		- MAIN_RUN: 0
		- CMAKE_STAIRS: 10
	2. Build the project: "cmake .." "make -j4"
	3. Copy-paste all files "*.res" from the folder "resultR" 
	   to "inv-dyn/sanity check/reference_data"
	4. Execute (with Matlab or Octave) the file "extract.m"
	5. Copy-paste the file "inv_dyn_files/inv_dyn_data_input.txt" 
	   at the location of the binary "exe_projectRobotran" (i.e. "workR/build")
	6. In "workR/CMakeList.txt", change the parameter MAIN_RUN to 5
	7. Build and execute the project: "cmake .." "make -j4"
	8. Copy-paste the file "workR/build/inv_dyn_data_output.txt" in the folder
	   "inv_dyn_files"
	9. Execute the file "analyze_output.m". 
	   A comparison between the torques and the muscles stimulations is made


NB: to get similar results, it is recommended to remove the noise
file "userFiles/ctrl/useful/noise/Noise.hh: double NewNoise() { return 0.0; }
instead of double NewNoise() { return (rnd() - 0.5) * (2.0 * max_noise); }




---------------------------
Procedure for an experiment
---------------------------

	1. Execute (with Matlab or Octave) the file "extract.m" in one of the folder
		- "experiment-level"
		- "experiment-stairs-ascending"
		- or "experiment-stairs-descending" 
	2. Copy-paste the file "inv_dyn_files/inv_dyn_data_input.txt" 
	   at the location of the binary "exe_projectRobotran" (i.e. "workR/build")
	3. In "workR/CMakeList.txt", change the parameter MAIN_RUN to 5
	4. Build the project: "cmake .." "make -j4"
	5. Copy-paste the file "workR/build/inv_dyn_data_output.txt" in the folder
	   "inv_dyn_files"
	6. Execute the file "analyze_output.m". 
	   A comparison between the torques and the power is made




NB: to get similar results, it is recommended to remove the noise
file "userFiles/ctrl/useful/noise/Noise.hh: double NewNoise() { return 0.0; }
instead of double NewNoise() { return (rnd() - 0.5) * (2.0 * max_noise); }







----------------------------------------------------------
Content of the file "inv_dyn_files/inv_dyn_data_input.txt"
----------------------------------------------------------

Abbreviations: 	H = hip; K = knee; A = Ankle
		R = Right; L = Left
		Q = joint position; QD = joint derivative

First line: number of lines-1 number of columns
Columns	1:	time
	2:	H_L_Q
	3:	H_L_QD
	4:	K_L_Q
	5:	K_L_QD
	6:	A_L_Q
	7:	A_L_QD
	8:	H_R_Q
	9:	H_R_QD
	10:	K_R_Q
	11:	K_R_QD	
	12:	A_R_Q
	13:	A_R_QD
	14:	F_Lfoot force on the left foot
	15:	F_Rfoot force on the right foot
	16-18:	IMU_acc in x,y,z
	19-21:	IMU_ang in x,y,z
	22-30:	IMU_or  in xx,xy,xz,yx,yy,yz,zx,zy,zz
	31:	H_L_Qq_ref_IDM
	32:	K_L_Qq_ref_IDM
	33:	A_L_Qq_ref_IDM
	34:	H_R_Qq_ref_IDM
	35:	K_R_Qq_ref_IDM
	36:	A_R_Qq_ref_IDM



-----------------------------------------------------------
Content of the file "inv_dyn_files/inv_dyn_data_output.txt"
-----------------------------------------------------------

Abbreviations: 	Qq = joint torque

Columns	1:	time
	2:	TorsoYaw	Qq
	3:	TorsoPitch	Qq
	4:	TorsoRoll	Qq
	5:	RightHipPitch	Qq
	6:	LeftHipPitch	Qq
	7:	RightHipRoll	Qq
	8:	RightHipYaw	Qq
	9:	RightKneePitch	Qq
	10:	RightFootPitch	Qq
	11:	RightFootRoll	Qq	
	12:	LeftHipRoll	Qq
	13:	LeftHipYaw	Qq
	14:	LeftKneePitch	Qq
	15:	LeftFootPitch	Qq
	16:	LeftFootRoll	Qq
	17:	RightShPitch	Qq
	18:	RightShRoll	Qq
	19:	RightShYaw	Qq
	20:	RightElbPitch	Qq
	21:	LeftShPitch	Qq
	22:	LeftShRoll	Qq
	23:	LeftShYaw   	Qq
	24:	LeftElbPitch	Qq
	25:	LSwing
	26:	RSwing
	27:	CPG_X_RG_1
	28:	CPG_X_RG_2
	29:	CPG_X_RG_3
	30:	CPG_X_RG_4
	31:	CPG_X_PF_1
	32:	CPG_X_PF_2
	33:	CPG_X_PF_3
	34:	CPG_X_PF_4
	35:	CPG_X_PF_5
	36:	CPG_X_PF_6
	37:	l_MTU SOL
	38:	q_LeftHipPitch
	39:	STIM_L_SOL
	40:	STIM_L_TA
	41:	STIM_L_GAS
	42:	STIM_L_VAS
	43:	STIM_L_HAM
	44:	STIM_L_GLU
	45:	STIM_L_HFL
	46:	STIM_L_RF
	47:	STIM_L_BFSH
	48:	STIM_L_HAB
	49:	STIM_L_HAD
	50:	STIM_L_HER
	51:	STIM_L_HIR
	52:	STIM_L_EVE
	53:	STIM_L_INV
	54:	STIM_R_SOL
	55:	STIM_R_TA
	56:	STIM_R_GAS
	57:	STIM_R_VAS
	58:	STIM_R_HAM
	59:	STIM_R_GLU
	60:	STIM_R_HFL
	61:	STIM_R_RF
	62:	STIM_R_BFSH
	63:	STIM_R_HAB
	64:	STIM_R_HAD
	65:	STIM_R_HER
	66:	STIM_R_HIR
	67:	STIM_R_EVE
	68:	STIM_R_INV
	69:	STIM_L_REF_SOL
	70:	STIM_L_REF_TA
	71:	STIM_L_REF_GAS
	72:	STIM_L_REF_VAS
	73:	STIM_L_REF_HAM
	74:	STIM_L_REF_GLU
	75:	STIM_L_REF_HFL
	76:	STIM_L_REF_RF
	77:	STIM_L_REF_BFSH
	78:	STIM_L_REF_HAB
	79:	STIM_L_REF_HAD
	80:	STIM_L_REF_HER
	81:	STIM_L_REF_HIR
	82:	STIM_L_REF_EVE
	83:	STIM_L_REF_INV
	84:	STIM_R_REF_SOL
	85:	STIM_R_REF_TA
	86:	STIM_R_REF_GAS
	87:	STIM_R_REF_VAS
	88:	STIM_R_REF_HAM
	89:	STIM_R_REF_GLU
	90:	STIM_R_REF_HFL
	91:	STIM_R_REF_RF
	92:	STIM_R_REF_BFSH
	93:	STIM_R_REF_HAB
	94:	STIM_R_REF_HAD
	95:	STIM_R_REF_HER
	96:	STIM_R_REF_HIR
	97:	STIM_R_REF_EVE
	98:	STIM_R_REF_INV



-----------------------------------------------------------
Content of the file "inv_dyn_files/inv_dyn_data_mom_pow.txt"
-----------------------------------------------------------

Columns	1:	time
	2:	mom_h_l_sag 
	3:	mom_k_l_sag
	4:	mom_a_l_sag
	5:	mom_h_r_sag
	6:	mom_k_r_sag
	7:	mom_a_r_sag
	8:	pow_h_l_sag
	9:	pow_k_l_sag
	10:	pow_a_l_sag
	11:	pow_h_r_sag
	12:	pow_k_r_sag
	13:	pow_a_r_sag




