## 5 Implementation
### Plant Modeling and Simulation  
In this work, a simulation of an assumed UAV was presented. Although the detailed modeling process of the system is beyond the scope of this study, a subjective description of the level of abstraction related to actuator failure and reconfigurability mechanisms is elaborated in this section.  
Nowadays, the advancements of modeling software and efficient computers enable the simulation of highly abstracted models. Multibody modeling tools allow the development of high-fidelity simulation models without getting into the complexity of the mathematical modeling of a system [17]. In this modeling process, SOLIDWORKS 3D CAD modeling software was employed to model the digital copy of the UAV structure with its inertial parameters. In contrast, physical models, such as D.C. motors, R.C. servo motors, and other relevant components, were modeled with Simscape MultibodyTM. It is an extension of MATLAB/Simulink. It has tools to simulate a mechanical system with multiple degrees of freedom which allows modeling the individual components and their integration, including their energy interaction [18]. The library contains all the blocks required to define physical systems, such as bodies, joints, actuators, and sensors. The solver simulates the dynamics of the physical system by developing and solving differential equations [19].  
The block diagram of the UAV HFM developed in Simscape MultibodyTM is shown in Figure 7. Inside the UAV block, the inertial properties of the UAV were defined by a body block that contained a CAD file of the UAV airframe. Based on the XML file generated from CAD, the relative position and orientation of components were specified by transformation block models, whereas the relative motion constraints were modeled in the joint block. The propulsion system was composed of two central units. The first unit was responsible for generating thrust, and it had a D.C. motor model block and propeller model block, while the second unit was responsible for vectorizing the generated thrust, and it had an R.C. servo motor model block and tilting mechanism model.  
Furthermore, these actuation blocks allow fault injection at a specified simulation time. The environmental model block was applied to define the gravitational force and model contact between the UAV and CAD modeled ground and obstacles. The translation and rotational state of the UAV with respect to the world reference were measured by transform sensor block. The propellers' angular rate and tilting angles were measured by sensor option on the respective joint block during the simulation. The model blocks are configured according to the manufacturer's datasheet of selected components.  
The controller block receives the position setpoint from the waypoint-based trajectory generator and the state of the UAV from the state measurement block. It outputs the control  
Figure 7: UAV system modeling and simulation block diagram.  
signal to the actuator block. The stabilization and control of the plant were implemented in the control block, which uses the cascaded closed-loop PID position and attitude control. The precomputed tilting angles combined with the fault tag are stored in the lookup table to reconfigure the UAV [20; 21; 22]. In this test platform, by assuming the presence of a perfect actuator fault detection and isolation system, fault signals were generated automatically, and corresponding reconfiguration parameters were selected after some detection time. Thus, each tilting mechanism servo received an actuation signal and executed structural reconfiguration.