@@ -1080,8 +1080,9 @@ def WrapperMain_function(target_folder, controller_type, wrapper_control_paramet
10801080 [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 ,
10811081 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 ,
10821082 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 ,
1083- 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 ,
1084- Delta_u_min ,nu_funnel ] = Gains .FunnelMRACwithBASELINE (mass_total_estimated , air_density_estimated , surface_area_estimated , drag_coefficient_matrix_estimated )
1083+ B_rot ,A_ref_rot ,B_ref_rot ,Q_rot ,P_rot ,Gamma_x_rot ,Gamma_r_rot ,Gamma_Theta_rot ,eta_max_funnel_tran ,M_funnel_tran ,u_max ,u_min ,
1084+ Delta_u_min ,nu_funnel_tran ,eta_max_funnel_rot ,M_funnel_rot ,Moment_max ,Moment_min ,Delta_Moment_min ,
1085+ nu_funnel_rot ] = Gains .FunnelMRACwithBASELINE (mass_total_estimated , air_density_estimated , surface_area_estimated , drag_coefficient_matrix_estimated )
10851086
10861087
10871088 #%% Control Algorithms ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -2647,7 +2648,8 @@ def FunnelMRACwithBASELINE(t, y):
26472648 K_hat_r_rot = y [70 :79 ] # \hat{K}_r (rotational)
26482649 Theta_hat_rot = y [79 :97 ] # \hat{\Theta} (rotational)
26492650 integral_e_rot = y [97 :100 ] # Integral of 'e_rot' = (angular_velocity - omega_ref)
2650- eta_funnel = y [100 ] # eta used to compute the funnel diameter
2651+ eta_funnel_tran = y [100 ] # eta used to compute the translational dynamics funnel diameter
2652+ eta_funnel_rot = y [101 ] # eta used to compute the rotational dynamics funnel diameter
26512653
26522654 K_hat_x_tran = np .matrix (K_hat_x_tran .reshape (6 ,3 ))
26532655 K_hat_r_tran = np .matrix (K_hat_r_tran .reshape (3 ,3 ))
@@ -2708,21 +2710,21 @@ def FunnelMRACwithBASELINE(t, y):
27082710 mu_adaptive_tran = K_hat_x_tran .T * x_tran + K_hat_r_tran .T * r_tran - Theta_hat_tran .T * Phi_adaptive_tran_augmented
27092711 mu_tran = mu_PD_baseline_tran + mu_baseline_tran + mu_adaptive_tran
27102712
2711- H_function_funnel = eta_bar_funnel - eta_funnel ** 2 - e_tran .T * M_funnel * e_tran
2712- Ve_funnel = (e_tran .T * P_tran * e_tran )/ H_function_funnel
2713+ H_function_funnel_tran = eta_max_funnel_tran - eta_funnel_tran ** 2 - e_tran .T * M_funnel_tran * e_tran
2714+ Ve_funnel_tran = (e_tran .T * P_tran * e_tran )/ H_function_funnel_tran
27132715
2714- K_hat_x_tran_dot = - Gamma_x_tran * x_tran * e_tran .T * (P_tran + M_funnel * Ve_funnel .item ()) * B_tran / H_function_funnel
2715- K_hat_r_tran_dot = - Gamma_r_tran * r_tran * e_tran .T * (P_tran + M_funnel * Ve_funnel .item ()) * B_tran / H_function_funnel
2716- Theta_hat_tran_dot = Gamma_Theta_tran * Phi_adaptive_tran_augmented * e_tran .T * (P_tran + M_funnel * Ve_funnel .item ()) * B_tran / H_function_funnel
2716+ K_hat_x_tran_dot = - Gamma_x_tran * x_tran * e_tran .T * (P_tran + M_funnel_tran * Ve_funnel_tran .item ()) * B_tran / H_function_funnel_tran
2717+ K_hat_r_tran_dot = - Gamma_r_tran * r_tran * e_tran .T * (P_tran + M_funnel_tran * Ve_funnel_tran .item ()) * B_tran / H_function_funnel_tran
2718+ Theta_hat_tran_dot = Gamma_Theta_tran * Phi_adaptive_tran_augmented * e_tran .T * (P_tran + M_funnel_tran * Ve_funnel_tran .item ()) * B_tran / H_function_funnel_tran
27172719
27182720 mu_x = mu_tran [0 ].item ()
27192721 mu_y = mu_tran [1 ].item ()
27202722 mu_z = mu_tran [2 ].item ()
27212723
27222724 u1 = math .sqrt (mu_x ** 2 + mu_y ** 2 + (mass_total_estimated * G_acc - mu_z ) ** 2 )
27232725
2724- xi_funnel_temp = (u_max - u1 )/ max (u1 - u_min , Delta_u_min )
2725- xi_funnel = (e_tran .T * Q_tran * e_tran >= 2 * Ve_funnel * eta_funnel ** 2 * xi_funnel_temp + nu_funnel ) * (H_function_funnel > 0 ) * xi_funnel_temp
2726+ xi_funnel_tran_temp = (u_max - u1 )/ max (u1 - u_min , Delta_u_min )
2727+ xi_funnel_tran = (e_tran .T * Q_tran * e_tran >= 2 * Ve_funnel_tran * eta_funnel_tran ** 2 * xi_funnel_tran_temp + nu_funnel_tran ) * (H_function_funnel_tran > 0 ) * xi_funnel_tran_temp
27262728
27272729 calculation_var_A = - (1 / u1 ) * (mu_x * math .sin (yaw_ref ) - mu_y * math .cos (yaw_ref ))
27282730 roll_ref = math .atan2 (calculation_var_A , math .sqrt (1 - calculation_var_A ** 2 ))
@@ -2763,15 +2765,22 @@ def FunnelMRACwithBASELINE(t, y):
27632765 Phi_adaptive_rot_augmented = np .matrix (np .block ([[Moment_baseline_PI ],
27642766 [Phi_adaptive_rot ]]))
27652767
2766- K_hat_x_rot_dot = - Gamma_x_rot * angular_velocity * e_rot .T * P_rot * B_rot
2767- K_hat_r_rot_dot = - Gamma_r_rot * r_rot * e_rot .T * P_rot * B_rot
2768- Theta_hat_rot_dot = Gamma_Theta_rot * Phi_adaptive_rot_augmented * e_rot .T * P_rot * B_rot
2768+ H_function_funnel_rot = eta_max_funnel_rot - eta_funnel_rot ** 2 - e_rot .T * M_funnel_rot * e_rot
2769+ Ve_funnel_rot = (e_rot .T * P_rot * e_rot )/ H_function_funnel_rot
2770+
2771+ K_hat_x_rot_dot = - Gamma_x_rot * angular_velocity * e_rot .T * (P_rot + M_funnel_rot * Ve_funnel_rot .item ()) * B_rot / H_function_funnel_rot
2772+ K_hat_r_rot_dot = - Gamma_r_rot * r_rot * e_rot .T * (P_rot + M_funnel_rot * Ve_funnel_rot .item ()) * B_rot / H_function_funnel_rot
2773+ Theta_hat_rot_dot = Gamma_Theta_rot * Phi_adaptive_rot_augmented * e_rot .T * (P_rot + M_funnel_rot * Ve_funnel_rot .item ()) * B_rot / H_function_funnel_rot
27692774
27702775 Moment_baseline = np .cross (angular_velocity .ravel (), (I_matrix_estimated * angular_velocity ).ravel ()).reshape (3 ,1 )
27712776 Moment_adaptive = K_hat_x_rot .T * angular_velocity + K_hat_r_rot .T * r_rot - Theta_hat_rot .T * Phi_adaptive_rot_augmented
27722777
27732778 Moment = Moment_baseline_PI + Moment_baseline + Moment_adaptive
27742779
2780+ xi_funnel_rot_temp = (Moment_max - LA .norm (Moment ))/ max (LA .norm (Moment ) - Moment_min , Delta_Moment_min )
2781+ xi_funnel_rot = (e_rot .T * Q_rot * e_rot >= 2 * Ve_funnel_rot * eta_funnel_rot ** 2 * xi_funnel_rot_temp + nu_funnel_rot ) * (H_function_funnel_rot > 0 ) * xi_funnel_rot_temp
2782+
2783+
27752784 u2 = Moment [0 ].item ()
27762785 u3 = Moment [1 ].item ()
27772786 u4 = Moment [2 ].item ()
@@ -2789,7 +2798,8 @@ def FunnelMRACwithBASELINE(t, y):
27892798 dy [70 :79 ] = K_hat_r_rot_dot .reshape (9 ,1 )
27902799 dy [79 :97 ] = Theta_hat_rot_dot .reshape (18 ,1 )
27912800 dy [97 :100 ] = angular_velocity - omega_ref
2792- dy [100 ] = eta_funnel * xi_funnel
2801+ dy [100 ] = eta_funnel_tran * xi_funnel_tran
2802+ dy [101 ] = eta_funnel_rot * xi_funnel_rot
27932803
27942804 return np .array (dy )
27952805
@@ -3827,7 +3837,8 @@ def FunnelMRACwithBASELINE(t, y):
38273837 K_hat_r_rot = yout [70 :79 ] # \hat{K}_r (rotational)
38283838 Theta_hat_rot = yout [79 :97 ] # \hat{\Theta} (rotational)
38293839 integral_e_rot = yout [97 :100 ] # Integral of 'e_rot' = (angular_velocity - omega_ref)
3830- eta_funnel = yout [100 ] # eta used to compute the funnel diameter
3840+ eta_funnel_tran = yout [100 ] # eta used to compute the translational dynamics funnel diameter
3841+ eta_funnel_rot = yout [101 ] # eta used to compute the rotational dynamics funnel diameter
38313842 ###################################################################
38323843
38333844 # ----------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -4314,6 +4325,13 @@ def FunnelMRACwithBASELINE(t, y):
43144325 DATA ,
43154326 delimiter = ", " ,
43164327 fmt = '% s' )
4328+
4329+ elif controller_type == 'FunnelMRACwithBASELINE' :
4330+ # DATA saved in CSV file
4331+ np .savetxt ("DATA_FunnelMRACwithBASELINE.csv" ,
4332+ DATA ,
4333+ delimiter = ", " ,
4334+ fmt = '% s' )
43174335
43184336
43194337
0 commit comments