@@ -1069,6 +1069,117 @@ def HybridRobustTwoLayerMRACwithBASELINE(mass_total_estimated,air_density_estima
10691069 # end of HYBRID ROBUST TWO-LAYER MRAC WITH BASELINE
10701070 # ================================================================================================================================================================
10711071
1072-
1073-
1074-
1072+ # ================================================================================================================================================================
1073+ # FUNNEL MRAC WITH BASELINE
1074+ # ================================================================================================================================================================
1075+ def FunnelMRACwithBASELINE (mass_total_estimated ,air_density_estimated ,surface_area_estimated ,drag_coefficient_matrix_estimated ):
1076+
1077+ # Number of states to be integrated by RK4
1078+ number_of_states = 101
1079+ # Length of the array vector that will be exported
1080+ size_DATA = 74
1081+ # size_DATA = 94 # OLD data format
1082+
1083+ # ----------------------------------------------------------------
1084+ # Baseline Parameters
1085+ # ----------------------------------------------------------------
1086+
1087+ # **Translational** baseline parameters to let the reference model follow the user-defined model (mu_baseline_tran)
1088+ KP_tran = np .matrix (1 * np .diag ([5 ,5 ,6 ]))
1089+ KD_tran = np .matrix (1 * np .diag ([8 ,8 ,3 ]))
1090+ KI_tran = np .matrix (1 * np .diag ([1 ,1 ,0.1 ]))
1091+
1092+ # **Translational** parameters for the PD baseline controller (mu_PD_baseline_tran)
1093+ KP_tran_PD_baseline = np .matrix (1 * np .diag ([5 ,5 ,6 ]))
1094+ KD_tran_PD_baseline = np .matrix (1 * np .diag ([8 ,8 ,3 ]))
1095+
1096+ # **Rotational** baseline parameters
1097+ KP_rot = np .matrix (1 * np .diag ([100 ,100 ,50 ]))
1098+
1099+ # **Rotational** parameters for the PID baseline controller (Moment_baseline_PI)
1100+ KP_rot_PI_baseline = np .matrix (2 * np .diag ([1 ,1 ,0.5 ]))
1101+ KD_rot_PI_baseline = np .matrix (0.3 * np .diag ([1 ,1 ,0.5 ]))
1102+ KI_rot_PI_baseline = np .matrix (1 * np .diag ([1 ,1 ,0.5 ]))
1103+
1104+ K_P_omega_ref = np .matrix (1.5 * np .diag ([5 ,5 ,2 ]))
1105+
1106+ # ----------------------------------------------------------------
1107+ # Translational Parameters MRAC
1108+ # ----------------------------------------------------------------
1109+
1110+ # Plant parameters **Translational** dynamics
1111+ A_tran = np .block ([[np .zeros ((3 , 3 )), np .identity (3 )],
1112+ [np .zeros ((3 , 3 )), np .zeros ((3 , 3 ))]])
1113+
1114+ B_tran = np .matrix (np .block ([[np .zeros ((3 , 3 ))],
1115+ [np .identity (3 )]]))
1116+
1117+ A_tran_bar = A_tran # Estimated A_tran matrix
1118+ Lambda_bar = (1 / mass_total_estimated ) * np .identity (3 ) # Estimate of \Lambda
1119+ Theta_tran_adaptive_bar = air_density_estimated * surface_area_estimated * drag_coefficient_matrix_estimated
1120+
1121+ # **Translational** reference model parameters and estimates
1122+ A_ref_tran = np .block ([[np .zeros ((3 , 3 )), np .identity (3 )],
1123+ [ - KP_tran , - KD_tran ]])
1124+
1125+ B_ref_tran = np .matrix (np .block ([[np .zeros ((3 , 3 ))],
1126+ [(1 / mass_total_estimated )* np .identity (3 )]]))
1127+
1128+ # **Translational** adaptive parameters
1129+ Gamma_x_tran = np .matrix (5e2 * np .diag ([1 ,1 ,10 ,1 ,1 ,10 ])) # Adaptive rates
1130+ Gamma_r_tran = np .matrix (1e0 * np .diag ([1 ,1 ,1 ])) # Adaptive rates
1131+ Gamma_Theta_tran = np .matrix (1e0 * np .diag ([1 ,1 ,1 ,1 ,1 ,1 ])) # Adaptive rates
1132+
1133+ # **Translational** parameters Lyapunov equation
1134+ Q_tran = np .matrix (4e-3 * np .diag ([1 ,1 ,20 ,1 ,1 ,20 ]))
1135+ P_tran = np .matrix (linalg .solve_continuous_lyapunov (A_ref_tran .T , - Q_tran ))
1136+
1137+ # Estimates of the matrices that verify the matching conditions for the **Translational** dynamics.
1138+ # Used for baseline controller and to center constraining ellipsoid when using projection operator
1139+ K_x_tran_bar = (LA .pinv (B_tran * Lambda_bar )* (A_ref_tran - A_tran_bar )).T * np .matrix (1 * np .diag ([1 ,1 ,1 ]))
1140+ K_r_tran_bar = (LA .pinv (B_tran * Lambda_bar )* B_ref_tran ).T * np .matrix (1 * np .diag ([1 ,1 ,1 ]))
1141+
1142+ # ----------------------------------------------------------------
1143+ # Rotational Parameters MRAC
1144+ # ----------------------------------------------------------------
1145+
1146+ # Plant parameters **Rotational** dynamics
1147+ A_rot = np .matrix (np .zeros ((3 ,3 )))
1148+ B_rot = np .matrix (np .eye (3 ))
1149+
1150+ # **Rotational** reference model parameters
1151+ A_ref_rot = - K_P_omega_ref
1152+ B_ref_rot = np .matrix (np .eye (3 ))
1153+
1154+ # **Rotational** parameters Lyapunov equation
1155+ Q_rot = np .matrix (7e-3 * np .diag ([1 ,1 ,1 ]))
1156+ P_rot = np .matrix (linalg .solve_continuous_lyapunov (A_ref_rot .T , - Q_rot ))
1157+
1158+ # **Rotational** adaptive parameters
1159+ Gamma_x_rot = np .matrix (1e1 * np .diag ([1 ,1 ,1 ])) # Adaptive rates
1160+ Gamma_r_rot = np .matrix (1e-4 * np .diag ([1 ,1 ,1 ])) # Adaptive rates
1161+ Gamma_Theta_rot = np .matrix (1e0 * np .diag ([1 ,1 ,1 ,1 ,1 ,1 ])) # Adaptive rates
1162+
1163+ # ----------------------------------------------------------------
1164+ # Funnel Parameters MRAC
1165+ # ----------------------------------------------------------------
1166+
1167+ eta_bar_funnel = 1
1168+ M_funnel = np .matrix (1e0 * np .diag ([1 ,1 ,1 ,1 ,1 ,1 ])) # n x n
1169+ u_max = 85
1170+ u_min = 0
1171+ Delta_u_min = 5
1172+ nu_funnel = 0.01
1173+
1174+ return [number_of_states ,size_DATA ,KP_tran ,KD_tran ,KI_tran ,KP_tran_PD_baseline ,KD_tran_PD_baseline ,KP_rot ,KP_rot_PI_baseline ,
1175+ KD_rot_PI_baseline ,KI_rot_PI_baseline ,K_P_omega_ref ,A_tran ,B_tran ,A_tran_bar ,Lambda_bar ,Theta_tran_adaptive_bar ,
1176+ A_ref_tran ,B_ref_tran ,Gamma_x_tran ,Gamma_r_tran ,Gamma_Theta_tran ,Gamma_Theta_tran ,Q_tran ,P_tran ,K_x_tran_bar ,K_r_tran_bar ,A_rot ,
1177+ B_rot ,A_ref_rot ,B_ref_rot ,Q_rot ,P_rot ,Gamma_x_rot ,Gamma_r_rot ,Gamma_Theta_rot ,eta_bar_funnel ,M_funnel ,u_max ,u_min ,
1178+ Delta_u_min ,nu_funnel ]
1179+ # ================================================================================================================================================================
1180+ # end of FUNNEL MRAC WITH BASELINE
1181+ # ================================================================================================================================================================
1182+
1183+
1184+
1185+
0 commit comments