3939
4040#include < fstream>
4141#include < nlohmann/json.hpp>
42+ #include < Eigen/Dense>
4243
4344// Forward declaration of MultiThreadedNode class
4445class MultiThreadedNode ;
@@ -50,9 +51,11 @@ class MultiThreadedNode;
5051// Define named constants for controller types
5152#define __PID__ 1
5253#define __MRAC__ 2
54+ #define __TWO_LAYER_MRAC__ 3
55+ #define __FUNNEL_TWO_LAYER_MRAC__ 4
5356
5457// SELECT here the CONTROLLER you want to run -----------------------------------------------------------------------
55- #define SELECTED_CONTROLLER __MRAC__
58+ #define SELECTED_CONTROLLER __FUNNEL_TWO_LAYER_MRAC__
5659// ------------------------------------------------------------------------------------------------------------------
5760
5861// Define ControlType based on SELECTED_CONTROLLER using type aliasing
@@ -68,10 +71,41 @@ using ControlType = PID;
6871#include " logging_mrac.hpp"
6972using ControlType = MRAC;
7073
74+ #elif SELECTED_CONTROLLER == __TWO_LAYER_MRAC__
75+
76+ #include " two_layer_mrac.hpp"
77+ #include " logging_two_layer_mrac.hpp"
78+ using ControlType = TwoLayerMRAC;
79+
80+ #elif SELECTED_CONTROLLER == __FUNNEL_TWO_LAYER_MRAC__
81+
82+ #include " funnel_two_layer_mrac.hpp"
83+ #include " logging_funnel_two_layer_mrac.hpp"
84+ using ControlType = FunnelTwoLayerMRAC;
85+
7186#else
7287#error "ERROR: Unsupported controller type selected."
7388#endif
7489
90+ namespace config_param {
91+
92+ // Flag for publishing data to the motors
93+ inline constexpr bool PUBLISH_ACTUATOR_MOTORS_FLAG = true ;
94+
95+ // Flag to enable/disable the MRAC projection operator
96+ inline constexpr bool USE_PROJECTION_OPERATOR = true ;
97+
98+ // Flag to enable/disable the debug logger
99+ inline constexpr bool USE_DEBUG_LOGGER = false ;
100+
101+ // Flag to enable/disable the safety mechanism between outer and inner loop
102+ inline constexpr bool USE_OUTER_LOOP_SAFETY_MECHANISM = true ;
103+
104+ // Flag to enable/disable motor failure
105+ inline constexpr bool ENABLE_MOTOR_FAILURE = false ;
106+
107+ } // namespace config_param
108+
75109
76110/* ********************************************************************************************************************
77111 Configurations Parameters set from config.json
@@ -85,6 +119,16 @@ struct ConfigurationParameters
85119 // Time in seconds for which the UAV will perform hovering after having completed the user-defined trajectory
86120 double hover_after_trajectory_time_seconds;
87121
122+ // Time in seconds at which motor failure happens (start)
123+ double motor_failure_start_time_seconds;
124+
125+ // Time in seconds for the motor failure duration
126+ double motor_failure_duration_time_seconds;
127+
128+ // Array containing the motor efficiencies to simulate motor failure. Order: T1, T2, ..., T8.
129+ // A "zero" turns off the motor completely, a "one" means the motor works as usual.
130+ Eigen::Matrix<double , 8 , 1 > motor_failure_efficiencies;
131+
88132 static ConfigurationParameters readConfigurationParametersFile (const std::string& configFileName);
89133
90134};
@@ -95,9 +139,6 @@ struct ConfigurationParameters
95139*/
96140struct GlobalParameters
97141{
98- // Flag for publishing data to the motors
99- bool PUBLISH_ACTUATOR_MOTORS_FLAG;
100-
101142 // Time in seconds at which we arm the motors
102143 double ARM_START_TIME_SECONDS;
103144
@@ -117,6 +158,12 @@ struct GlobalParameters
117158 // This must always be performed before takeoff
118159 double OFFSET_ODOMETRY_TIME_SECONDS;
119160
161+ // Time in seconds at which motor failure happens (start)
162+ double MOTOR_FAILURE_START_TIME_SECONDS;
163+
164+ // Time in seconds at which motor failure is resolved (end)
165+ double MOTOR_FAILURE_END_TIME_SECONDS;
166+
120167 // Default constructor
121168 GlobalParameters () = default ;
122169
0 commit comments