The Model file of uav physical Model is model.slx. Open it and you can see the content as shown below:
It can be seen that the model consists of two large modules: the Actuator and the Kinematic_Equation. Each module is a subsystem, which contains more modules, somewhat similar to the function encapsulation when writing code. Click in to see details inside the module.
Now let’s talk about the design of the two modules of Actuator and Kinematic_Equation respectively.
Actuator modeling
Actuator is the device that provides power. For UAV, actuator is the motor fixed at the end of the arm, and it is generally brushless motor. In addition to the motor, there will be electricity transfer to drive the motor. The characteristics of electrical regulation will change the corresponding speed and control accuracy of the motor, so strictly speaking, electrical regulation should also be included in the model of the actuator.
When we are given a PWM signal, the signal will be transmitted to the electrical control controller, and then the electrical control output voltage control motor. When we are given a PWM instruction, the motor will not immediately reach the target speed, but there will be a delay, the delay will be related to the electric adjustment, the motor. Here, we reduce it to a first-order inertia link:
Where is the time constant. In addition, we also need to know the relationship between the input PWM wave and the actual motor speed. Because according to the previous formula, we can know that the force and torque generated by the motor are corresponding to the speed of the motor. In the electric conditioning, in fact, there is a controller, generally PID controller, to the motor speed feedback control, so we can think of the motor speed with the input PWM signal duty ratio is linear correlation.
Therefore, the actuator model realized by Simulink is shown as follows:
Now we are going to model the motor. Here we focus only on the main effects of the motor, such as the torque and force generated, and ignore those secondary effects, such as the electromagnetic induction. According to the formula of motor torque and force generated in the previous chapter, we can build Simulink module, the specific implementation details, you can refer to the source code of the model, here is no longer too redundant.
Dynamic equation
Now let’s talk about the dynamics of the drone. Dynamic equation is a basic physical equation describing the motion of a rigid body. It describes the motion state of a rigid body under the action of external forces. Our drone is a rigid body with four motors attached to the end of the arm. When the motor rotates, the four motors all produce an upward force, the sum of the four forces is the total tension. In addition to providing lift, this tension creates a torque that causes the body to spin.
The following figure shows the Simulink model of attitude dynamics:
Inertia_Matrix on the far left is the moment of inertia of the body, which can be measured experimentally or calculated theoretically. Here we assume that the body is perfectly symmetrical, so only the diagonal lines have elements.
The Quaternion_Update module uses the runge-Kutta algorithm of order 1 to update quaternions.
Among themRepresents the angular velocity of b system measured in B system relative to N system.
Then we take a look at the dynamic model of the position, as shown in the figure below:
The dynamics of the position used here have also been described in previous chapters. Here is the body_to_earch module, which is used for coordinate transformation, that is, from B system to I system. The rotation matrix used is:
Among themIs the attitude quaternion.
The simulation
Once the model is built, we can do a simple simulation to test the performance of the model. As shown below, we input four same PWM signals to the model, with a PWM value of 1500, indicating that the throttle is in the middle. So what we expect is that the aircraft will accelerate vertically in the most uniform way.
The following are some of the simulation results, which are consistent with our expectations.
The content is selected from The Development of Model-based (Simulik/Matlab) Control. For more information, please add jiayue199506 on wechat.