Tuning a Drone Flight Control System without FlightFollow project
|1||Arduino, Uno Rev 3||715-4081|
|1||Arduino, 9 Axis Motion Shield||865-9001|
|4||STMicroelectronics Electronic Speed Controller Discovery Kit 32 Bit MCU Discovery Kit B-G431B-ESC1||193-9781|
|1||Lithium Polymer Battery|
|4||Turnigy 2830 900KV L2215J-900 Brushless Motor|
|1||HC-SR04 Ultrasonic Sensor|
|1||HC-06 Bluetooth module|
|1||DJI F450 drone frame|
|1||Nylon 1045 Bladed Propeller|
The research for quadcopters with regards to control and autonomy encounters multiple challenges. Quadcopters are inherently non-linear systems with a smaller number of control inputs than degrees of freedom (DOF), resulting in an underactuated system. Therefore, they are a challenge to control especially when the quadcopter operates outwith normal conditions. Proportional, integral and derivative (PID) controllers are the most widely used control method in the case of quadcopters. However, these are time consuming and often require experiments to tune the controller, as the controllers are sensitive to the layout of the drone. With drones currently being utilised in such wide areas, there is a desire to change payloads, such as monitoring equipment, readily. Currently, the majority of flight control systems are designed for a set range of payloads or the controller is re-tuned to new layouts.
Therefore in this project, the focus was to develop a method for allowing rapid prototyping and retuning of flight control system for drones.
In order to tune the flight control system for the drone, a high fidelity mathematical model was developed on MATLAB Simulink. The dynamic model developed was a 6 degree of freedom (DOF) simulation of a quadcopter powered by 4 brushless direct current motors (BLDC) based on the Newton-Euler method (Figure 1). This model basically allowed the quadcopter to fly in a simulated world, taking into account several forces and moments such as aerodynamic drag, thrust, gravity and gyroscopic moment.
Figure 1 - Drone Reference Frame and Layout
Now that the dynamics and kinematics are defined the method was applied to a mathematical model via MATLAB Simulink. It incorporates a built-in ordinary differential equation (ODE) solver, based on Runge-Kutta 4 (RK4) with a set time step of 0.01 seconds. There are three main aspects of the model, Guidance, Control, and the plant (dynamic) model. The results visualisation sub system was used for debugging and testing. The model can be seen in Figure 2.
Figure 2 - Full system Model
The resultant model now allows for the development and tuning of a flight control system of a quadcopter. Control of the drone is critical due to the non-linear and underactuated characteristics of the system. The control design chosen utilises PID controllers. It takes in the next and position and the desired course and outputs the actuator motor command as a PWM signal. The control system layout is shown in Figure 3.
Figure 3 - Control system flow diagram
Physical Design Implementation
To validate the model, a physical implementation of the control system was required. Therefore, a quadcopter was designed and the parameters from this prototype were fed back into the Simulink model. The controller was then tuned to the physical design on the model, and the tuned controller was implemented using a customisable microcontroller. Due to time constraints, only the pitch, roll and altitude controller were tested.
The design of the quadcopter was based on the modelling approach and can be seen in figure 4. It was a quadcopter with 4 BLDC motors that controlled attitude, position and altitude. The components selected can be seen in the bill of materials. The rotor system, including the motor and propeller, were chosen first based on lift ability and the rest of the components were chosen for compatibility with other chosen components.
Figure 4 - Drone design
The flight controller unit of this design is the most important aspect. It takes in all the sensor reading and commands from the ground control station and processes these to allow the drone to perform various manoeuvres. Since the designed flight controller was custom built, a programmable Arduino Uno microcontroller was chosen. This allowed for straightforward application and rapid prototyping of the control algorithm.
The flight control system developed in MATLAB Simulink was converted to C++ code manually. Initially, the MATLAB C++ encoder was used but led to multiple problems. Subsequently, due to time constraints, the flight control system developed only represents the pitch, roll and altitude controllers. To wire up the sensors and the ESC a breadboard was used as it allowed for rapid changes to the circuit layout. If the drone were built for real-life applications, the connection would be soldered.
Applying the Design to the Simulation
The mathematical model developed requires certain values from the drone design to be implemented in the model. The thrust force and drag moment was calculated experimentally and the mass of each component was measured with the moment of inertia of the drone calculated using these measured values.
Once the flight controller was tuned via the mathematical model and uploaded to the microcontroller, the quadcopter was built and wired as shown in Figure 4. According to the Civil Aviation Authorities, the designed drone is within the A3 category and therefore, if flown outside must be flown 150 meters away from residential properties and 50 meters away from uninvolved people. Due to Covid-19 and the pandemic, a suitable test area was not available and thus the drone was tested inside. For safety, the drone was tethered to anchor points with a movement range to allow for take-off and hover. For the experiment, the drone was tasked to take-off, accelerate to a desired altitude, and then hover, after which the drone then was commanded to land.
Figure 5 - Physical Experiment Set up
The goal of this project was to implement a 6-DOF dynamic model of a drone, which would allow for the rapid prototyping and development of a flight control software, tuned to the dynamic model. It was then to be tested through the physical implementation of a flight controller tuned via the dynamic model.
The designed drone was implemented into the dynamic model and the flight control system was developed and tuned around that. The tuned flight control system was then implemented into a physical design where it allowed for a drone to take off, hover at a set altitude and land.
This project still has some future development which is currently being conducted. From the physical tests, it shows a good foundation in allowing for tuning of flight controllers to specific drone setups. Further work is required on validating the model. This can be done by additional tests once a suitable test site is found. To improve the accuracy of the simulation compared to real-world applications other factors such as wind, sensors, electronic noise and ground effect should be modelled in the simulation.
Additionally, it would be great to be able to expand on the autonomous side of this project, the current design has rudimentary autonomous capabilities where it can currently be told set waypoints and fly to them. However, there is no accurate obstacle avoidance which is essential for an autonomous drone.