# Matlab代写｜ESE 4481 ASSIGNMENT #3: DYNAMICS

这是一篇美国的Matlab无人机动力学程序代写

This is not a partner assignment. Please work individually. Do not plagiarise.

Write your own code. Make your own model.

Please submit all answers in a self-contained short report that answers all questions.

This assignment is to help you grasp dynamics. It walks through the derivation of conservation of translational and angular momentum for the UAV. The dynamics are derived i a frame centered at the c.g. of the UAV and rotating with the aircraft’s principle axes, the body frame.

The derivation in this homework assignment makes practical assumptions. A simplified dynamics for the quadcopter may satisfy the following 5 assumptions [1]:

*X *is a force in the *x *body axis. *Y *is a force in the *y *body axis. *Z *is a force in the *z *body axis. *L *is a moment about the body *x *axis. *M *is a moment about body *y *axis. *N *is a moment about the body *z *axis.

Assume the standard aerospace notation discussed in class holds with (Z-Y-X) euler angles. *ϕ *is the roll euler angle between the earth (NED) frame and the body frame. *θ *is the pitch euler angle between the earth frame and the body frame. *ψ *is the yaw euler angle between the earth frame and the body frame.

Recall that a vector in the body frame *p*b can represented as follows:

*(4.1) p*b = *R*bE*p*E = *R*(*ϕ*)*R*(*θ*)*R*(*ψ*)*p*E*, *

where *p**E *is the vector as measured in the earth frame.

Assume that *V **b *is the airspeed vector as measured in the body frame with components as follows:

*V *b = *u**v**w*

The linear momentum of the UAV is *P**, *

*P *= *mV, *

and the angular momentum of the UAV is

*H *= *Jω. *

For the time being, assume that the rotors do not spin and are also fixed so that they do not contribute to angular momentum.

Newton’s 2nd law applied to a quadcopter can be written in the earth frame (inertial frame) as follows:

(5.2) *F*E = *d **dt *(*P*) E*,*

where *m *is the mass of the UAV, *V *is the translational velocity of the body, *ω*b/E is the angular velocity of the body, and *F *and *M* represent applied moments and forces,

(5.3) *M*E = *d **dt *(*H*) E*,*

Rewrite (5.2) in a frame that rotates relative to the earth frame, the body frame.

Assume that the centers of the body frame and the earth frame are coincident, but the body frame rotates relative to the earth frame by *ω*b/E. These laws now take the form under the assumption of constant mass and mass distribution:

(5.4)˙*V **b *= 1/*m **（F**b **− **ω*b/E *× **mV **b）**, *

(5.5)˙*ω*b/E = *J**−*1 （*M**b **− **ω*b/E *× **Jω*b/E） *. *

Create a simulink diagram that models these equations with *F, M *as inputs and *V, ω *as outputs. Assume that *m*, the mass of the quadcopter with prop guards (68g), and *J*, the moment of inertia with prop guards, are constants (reusing values from your previous homework).

Recall that the rate of change of the euler angles˙*ϕ*, *θ*˙,˙*ψ *is not the same as the body axis rotational rate that would be measured in a gyroscope *p*, *q*, and *r*.

The rate of change of euler angles can be thought of as the magnitude of angular velocity vectors for the Earth axis [2].

Changing the sum of the vectors rotated to the body axis frame, form the familiar roll rate, pitch rate, and yaw rate. This is done as follows (recalling the Z-Y-X order):

(6.1)

Let the vector Θ represent the euler angles,

Θ = (*ϕ, θ, ψ*)*T **. *

This yields the following expression that relates the rate of change of euler angles x to the angular velocities roll rate, pitch rate, and yaw rate *ω*b/E = (*p, q, r*)*T **. *

(6.2)

where *H *is the matrix in (6.2). To calculate the rate of change of euler angles in terms of angular rates the equation is inverted as follows

*(6.4)˙Θ =H*(Θ)*−*1*ω*b/E

Construct a simulink diagram that takes an input *ω *and outputs Θ*. *These equations will have singularities so please note when these equations are invalid.

Transform the gravity vector from the earth frame to the body frame. Assume that gravity points downwards and has a constant acceleration 9*.*81 m/s. Write out the gravity vector in body coordinates as a function of *ϕ *and *θ*.

*(7.1)F**gb *= *R*bE*F**g*E

Create a simulink diagram that models gravity in the body frame. Construct a simulink diagram that takes an input Θ and outputs *F**gb**. *

The speed of the Parrot’s four propellers is *n*1, *n*2, *n*3 , and *n*4. Use units of Hz for motor speeds.Assume that the *x *distance from the UAV center of mass to a rotor’s center:

*W *= 0*.*047625;

Assume that the *y *distance from the UAV center of mass to a rotor’s center:

*L *= 0*.*047625;