2. V. K. Jadon, Prof., Mechanical Engineering, Chitkara University
Simulation
ControllerDesign β 2D
2D Model
The
Flow
β¦. ControllerDesign β 1D
1D Model
3. 1D Model of Quadcopter
π α·π§ π‘ = π’ π‘ β ππ
π₯1 = π§(π‘)
π₯2 = αΆπ§ t
changing variables into state variables:
π’ π‘ = π’1
= αΆπ₯1
In state-space modelling, we want to see the dynamics
of the each states.
αΆπ₯1 = π₯2 αΆπ₯2 =
1
π
π’1 β π
Two initialconditionsare required to solve these first
order differential equationson the state; π₯1(0) and π₯2(0).
π₯1 0 = π§ 0 = 0 π₯2 0 = αΆπ§ 0 = 0
ππ
π2
π3
π2
π3
π’1
π§ = π§ πππ
scipy.integrate.odeint(func, y0, t, args=(), tfirst=False)
Function model
V K Jadon, Prof., Mechanical Engineering, Chitkara University
def model(z,t,u):
x1=z[0] # Intial Conditionfor First
FODE
x2=z[1] # Initial conditionfor
Second FODE
dx1dt=x2 # First FODE
dx2dt=(u-c*x2-k*x1)/mass-gravity # Second FODE
dxdt = [dx1dt,dx2dt]
return dxdt
5. Control Equation
ππ
π¦
π§
π’1
π§β²β²
π‘ = βπ +
π’1
π
π‘ (1)
π = π§ πππ β π§
πβ² = π§β² πππ β π§β²
The error term π and πβ² will decay exponentiallyto zero if error
function satisfies the following second order differential equation:
πβ²β² + π π πβ² + π π π = 0
(π§ πππ
β²β²
βπ§β²β²
) + π π πβ²
+ π π π = 0
Substitutingfrom Eqn (1)
π§ πππ
β²β²
+ π β
π’1 π‘
π
+ π π πβ² + π π π = 0
π’1 π‘ = π(π§ πππ
β²β²
+ π + π π πβ² + π π π)
The above equationis the controller equation.
π, πβ² π’1
PD Controller
The input to the
controller is the current
and desired positions.
The output is the
control signal.
V K Jadon, Prof., Mechanical Engineering, Chitkara University
6. V K Jadon, Prof., Mechanical Engineering, Chitkara University
Interactive Mode Plotting
Interactivemode updates a plot each time a new command is issued.
Turn on interactivemode with method: plt.ion()
Turn off interactivemode with method: plt.ioff()
When interactivemode is not on, you enter all pyplot commands and then use the
method plt.show() to see the figure.
plt.clf() clears the entire current figure with all its axes, but leaves the window
opened, such that it may be reused for other plots.
plt.close() closes a window, which will be the current window, if not specified
otherwise.
8. αΆπ₯1
αΆπ₯2
αΆπ₯3
αΆπ₯4
αΆπ₯5
αΆπ₯6
=
π₯4
π₯5
π₯6
0
βg
0
+
0 0
0 0
0 0
β
1
π
π ππβ 0
1
π
πππ β 0
0
1
πΌ π₯π₯
+
π’1
π’2
π α·π¦ = ββ π’1
π α·π§ = π’1 β ππ
πΌ π₯π₯
α·β = π’2
2D Planar Model
Linearization
αΆπ₯1
αΆπ₯2
αΆπ₯3
αΆπ₯4
αΆπ₯5
αΆπ₯6
=
π₯4
π₯5
π₯6
0
βg
0
+
0 0
0 0
0 0
β
1
π
β 0
1
π
0
0
1
πΌ π₯π₯
+
π’1
π’2
The model and controller is designed for hover configuration
as it is more close to linear situation
π¦ πππ = π¦0;
π’1 = ππ; π’2 = 0;
π§ πππ = π§0; β πππ = 0
α·π¦ = βπβ
(1)
α·π§ = βπ +
π’1
π
(2)
α·β =
π’2
πΌ π₯π₯
(3)
Linearizationof the model for the hover becomes
V K Jadon, Prof., Mechanical Engineering, Chitkara University
β β 0
9. Linearized planer model is given by
π¦β²β²
= βπβ
..(1)
To solve these, transform into first order differential
equationsby defining the state variablesas below
π₯1 = π¦(π‘) π₯2 = π§(π‘) π₯3 = β (π‘)
π₯β²1 = π¦β² π‘ = π₯4 β¦ (4)
π₯β²2 = π§β² π‘ = π₯5 β¦ (5)
π₯β²3 = β β² π‘ = π₯6 β¦ (6)
SubstitutingEqn (4) into Eqn (1)
π₯β²4 = βπβ β¦(7)
SubstitutingEqn (5) into Eqn (2)
π₯β²5 = βπ +
π’1
π
β¦ (8)
SubstitutingEqn (6) into Eqn (3)
π₯β²6 =
π’2
πΌ π₯π₯
β¦ (9)
The solutionof FODE (4) to (9) gives six states variables.
π₯1, π₯2, π₯3, π₯4, π₯5, π₯6
These are positions(π¦, π§, β ) and their time
derivatives(π¦β², π§β², αΆβ β² )
Position and Time Derivatives
π§β²β²
= βπ +
π’1
π
β¦ (2)
β β²β²
=
π’2
πΌ π₯π₯
β¦ (3)
V K Jadon, Prof., Mechanical Engineering, Chitkara University
changing dots (.) with
dashes (β) for convenience
We need π’1 and π’2 to solve these set of FODE
π’1 and π’2 are output of control equation.
We need to design controllerfor getting
appropriatevaluesof π’1 and π’2
10. π’1, π’2 π¦, π§, β
The error (desired value-currentvalue) in roll angle and position
will reach to zero only if the error function satisfies the second
order differential equation.
πβ²β² + π π πβ² + π π π = 0
π¦ πππ
β²β²
β π¦β²β²
+ π ππ¦ π π¦
β²
+ π ππ¦ π π¦ = 0
Controller
π§ πππ
β²β²
β π§β²β²
+ π ππ§ π π§
β²
+ π ππ§ π π§ = 0
β π
β²β² β β β²β² + π πβ πβ
β²
+ π πβ πβ = 0
π¦ βTransllation
Controller
ππ’π‘ππ’π‘π¦, π¦ πππ
Thrust
Controller
π§, π§ πππ
Roll Controller
β , β π
ππ’π‘ππ’π‘
ππ’π‘ππ’π‘
V K Jadon, Prof., Mechanical Engineering, Chitkara University
12. V K Jadon, Prof., Mechanical Engineering, Chitkara University
In this problem we have three degrees of freedom (π¦, π§, β ) and two control
variables(π’1, π’2).
So, we need cascaded control system.
To reach the desired position we have to command a roll angle (β π) such
that required translation(π¦ πππ₯, π§ πππ ) is achieved.
Position
Controller
β π
β β² π
π¦ πππ , π¦β² πππ
π§ πππ , π§β² πππ
Roll
Controller
π’2
π’1
π¦, π§, β
π’1
Current states
π¦β², π§β², β β²
β , β β²
Control Block
13. Thanks
V K Jadon, Prof., Mechanical Engineering, Chitkara University 13