AE4610
  • Welcome
  • Experiments
  • Lab 0: MATLAB & SIMULINK
  • Lab 1: Rotary Servo Base
    • A. Integration (Week 1)
    • B. Modeling (Week 1)
    • C. Control Design (Week 2)
    • D. Controller Implementation & Evaluation (Week 3)
  • Lab 2: 3 DOF Gyroscope
    • A & B. Modeling and Control Design (Week 1)
    • C. Controller Implementation (Week 2)
  • Lab 3: Rotary Flexible Link
    • A. System Identification (Week 1)
    • B & C. Control Design and Controller Implementation (Week 2)
  • Lab 4: Rotary Inverted Pendulum
    • A & B. Modeling and Balance Control
    • C. Swing-up Control (Demo)
  • Final Project
  • Archive
    • Old Lab 1 Model Validation
    • Problem Set
    • DC Motor
    • Lab 1: Rotary Servo Base (Older Version)
      • A. Integration (Week 1)
      • B. Modelling (Week 1)
      • C. Position Control (Week 2)
    • Quadcopter
    • Gyroscope
    • Inverted Pendulum
    • 3DOF Helicopter
    • Torsional Pendulum
    • Aero LQR
      • A. System Identification
      • A. System Identification (Week 1) last check
      • B. Control Design & Implementation (Week 2)
    • Rotary Gyro
      • Rotary Gyro
    • 2 DOF AERO
      • A. System Identification
      • B. Control Design
      • C. Controller Implementation
    • Copy of Lab 4: Rotary Inverted Pendulum
      • Week 1
      • Week 2
Powered by GitBook
On this page
  • Controller Design
  • Background
  • Designing an LQR Controller
  • Controller Implementation
  • Desired Closed-Loop Response Specifications
  • Running the closed-loop state-feedback LQR simulation
  • Neglecting Coupling Effect
  • With Coupling Effect
  • Analysis Question

Was this helpful?

Export as PDF
  1. Archive
  2. Aero LQR

B. Control Design & Implementation (Week 2)

Controller Design

Background

Linear State-Space Representation

Given the linear state-space equations: x˙=Ax+Bu\dot{x}=Ax+Bux˙=Ax+Bu and y=Cx+Duy=Cx+Duy=Cx+Du, we define the state for the Quanser Aero Experiment as

x=\begin{bmatrix} \theta(t), & \psi (t), & \dot{\theta}(t), & \dot\psi(t) \end{bmatrix}^T \tag{38}

the output vector as y= \begin{bmatrix} \theta(t), & \psi(t), & \dot{\theta}(t), & \dot{\psi}(t) \end{bmatrix}^T \tag{39}

and the control variables as

u=\begin{bmatrix} V_\theta & V_\psi\end{bmatrix}^T \tag{40}

where θ\thetaθand ψ\psiψare the pitch and yaw angles, respectively, and VθV_\thetaVθ​and VψV_\psiVψ​ are the motor voltages applied to the pitch and yaw rotors (i.e. the main and tail rotors). Using the equations of motion in Equations (1) and (2), the state-space matrices are

A=\begin{bmatrix} 0&0&1&0\\ 0 &0&0&1\\ -K_{\theta}/J_\theta & 0& -D_\theta/J_\theta& 0 \\ 0 &0 &0&-D_\psi/J_\psi \end{bmatrix} \tag{41.a}​

B=\begin{bmatrix} 0& 0\\ 0&0\\ K_{\theta\theta}/J_\theta & K_{\theta\psi}/J_\theta \\ K_{\psi\theta}/J_{\psi} & K_{\psi\psi}/J_\psi \end{bmatrix} \tag{41.b}

C=\begin{bmatrix} 1&0&0&0\\ 0&1&0&0 \\ 0&0&1&0 \\ 0&0&0&1\end{bmatrix} \tag{41.c}

D=\begin{bmatrix} 0&0\\ 0&0 \\ 0&0\\ 0 & 0\end{bmatrix} \tag{41.d}

In this section, a state-feedback controller is designed to regulate the pitch and yaw angles of the Quanser Aero Experiment to desired angles. Using the previous state-space model, we can find a control gain KKK based on the coupled dynamics to stabilize the system. The control gains are computed using Linear-Quadratic Regulator (LQR) theory. The general state-feedback control is illustrated in Figure 11. The state-feedback controller is defined

u=K(x_d-x) \tag{42}

where xxx is the state defined in Equation (38)

x_d=\begin{bmatrix}\theta_d, & \psi_d, & 0,&0\end{bmatrix} ^ T\tag{43}

is the reference command (or setpoint) state with the desired pitch and yaw angles, θd\theta_dθd​ and ψd\psi_dψd​ , and

u=\begin{bmatrix} V_\theta&V_\psi\end{bmatrix} ^ T\tag{44}

is the control input where VθV_\thetaVθ​ is the front/pitch motor voltage and VψV_\psiVψ​ is the tail/yaw motor voltage.

Linear Quadratic Regulator (LQR) optimization can be used for finding the control gain parameters of the Quanser Aero Experiment flight control. Given the state-space representation, the LQR algorithm computes a control law uuu to minimize the performance criterion or cost function:J=\int_0^\infty(x_{\rm ref}-x(t))^TQ(x_{\rm ref}-x(t))+u(t)^TRu(t)dt. \tag{45}

The design matrices QQQ and RRR hold the penalties on the deviations of state variables from their setpoint and the control actions, respectively. When an element of QQQ is increased, therefore, the cost function increases the penalty associated with any deviations from the desired setpoint of that state variable, and thus the specific control gain will be larger. When the values of the RRR matrix are increased, a larger penalty is applied to the aggressiveness of the control action, and the control gains are uniformly decreased.

Since there are four states , Q∈R4×4Q\in \mathbb{R}^{4\times 4}Q∈R4×4, and two control variables, R∈R2×2R\in\mathbb{R}^{2\times 2}R∈R2×2 . The setpoint, xdx_dxd​ (Equation 43) is given above the control strategy used to minimize cost function J is thus given by

u=K(x_d-x)=k_{p,\theta}(\theta_d-\theta)+k_{p,\psi}(\psi_d-\psi)-k_{d,\theta}\dot\theta-k_{d,\psi}\dot\psi \tag{46}

Designing an LQR Controller

Various control software already has LQR optimization routines that can be used to generate the state feedback control gain KKK. In order for the closed-loop response to satisfy certain time-domain specifications, the closed-loop system is typically simulated using its dynamic model, in software, first. This is an iterative process. By adjusting the weighting matrices QQQ and RRR and then running the simulation, we can find a control that satisfies the user's requirements. Further, we must ensure that the control signal uuu is smooth (i.e. does not chatter) and does not surpass the limits of the actuator.

LQR Control Design and Simulation

LQR is used to find the state-feedback control gain KKK (KKK is 2×42\times 4 2×4matrix) that will stabilize the Quanser Aero Experiment to the user's desired pitch and yaw angles. Our desired closed-loop response should match the following specifications. Use MATLAB command K = lqr(A,B,Q,R) to obtain gain, KKK, matrix.

Desired closed-loop response specifications for pitch

  1. Steady-state error: pitch esse_{\rm ss}ess​ ≤ 2 deg⁡\degdeg, yaw esse_{\rm ss}ess​ ≤ 2 deg⁡\degdeg.

  2. Peak time: tpt_{\rm p}tp​ ≤ 2 s.

  3. Percent Overshoot: PO\rm POPO ≤ 7.5%.

  4. No actuator saturation: ∣Vψ∣|V_\psi|∣Vψ​∣ ≤ 24V and ∣Vθ∣|V_\theta|∣Vθ​∣ ≤ 24V .

The state-space matrices derived in Equation (41) are entered in the State-Space block in SIMULINK and the control gain is set to the MATLAB variable K.

Running the closed-loop state-feedback LQR simulation

  1. Using parameters from Part A, obtain state-space matrices of the system neglecting coupling effect.

  2. Design Q,RQ,RQ,R , and KKK. To start with try with following QQQ, RRR and KKK. Q = diag([200 75 0 0 ]); R = 0.01*eye(2,2); K = lqr(A,B,Q,R)

  3. Build the SIMULINK model of the system

  4. Simulate the closed-loop response of the system with pitch-only command: θd=10 deg⁡\theta_d=10\space \degθd​=10 deg. (Make sure to change deg to rad in SIMULINK)

  5. Simulate the closed-loop response of the system with yaw only command: ψd=45 deg⁡\psi_d=45 \space \degψd​=45 deg. (Make sure to change deg to rad in SIMULINK)

  6. Simulate the closed-loop response of the system with pitch and yaw command: θd=10 deg⁡\theta_d= 10\space \degθd​=10 deg and ψd=45 deg\psi_d = 45 \space \rm degψd​=45 deg. (Make sure to change deg to rad in SIMULINK)

  7. Check whether your controller meets the desired specifications.

  8. If it fails to meet the specifications, tune QQQ and/or RRR to meet the specifications

  9. Save the data and plot the closed-loop system response for pitch and yaw

  10. Now, use system matrices with coupling effect and use the controller without coupling

  11. Repeat steps 4-6

  12. The closed-loop response in this step does not have to meet the desired specifications

  13. Now, design Q,RQ,RQ,R , and KKK with the coupling effect

  14. Build the SIMULINK model of the system

  15. Repeat steps 4-6

  16. Check whether your controller meets the desired specifications.

  17. If it fails to meet the specifications, tune QQQ and/or RRR to meet the specifications

  18. Save the data and plot the closed-loop system response for pitch and yaw

Things to check

Analysis

  1. What happened when you neglect the coupling effect?

  2. Is there any systematic way to design QQQ and RRR ?

Controller Implementation

In this section, the state-feedback control is implemented on the Quanser Aero Experiment using the q_aero_2dof_lqr_control SIMULINK diagram shown in Figure 12 with QUARC.

Download the file into the quanser_aero folder that was used for Week 1.

Desired Closed-Loop Response Specifications

  1. Steady-state error: pitch esse_{\rm ss}ess​ ≤ 2 deg⁡\degdeg, yaw esse_{\rm ss}ess​ ≤ 2 deg⁡\degdeg.

  2. Peak time: tpt_{\rm p}tp​ ≤ 2 s.

  3. Percent Overshoot: POPOPO ≤ 7.5%.

  4. No actuator saturation: ∣Vψ∣|V_\psi|∣Vψ​∣ ≤ 24V and ∣Vθ∣|V_\theta|∣Vθ​∣ ≤ 24V .

Running the closed-loop state-feedback LQR simulation

Neglecting Coupling Effect

Pitch Command Only

  1. Unlock both pitch and yaw axes to enable the full 2 DOF motion.

  2. Open q_aero_2dof_lqr_control SIMULINK file.

  3. Use the gain KKK obtained in Part B. neglecting the coupling effect.

  4. Use pitch command (10 deg) only by changing Amp_y to zero.

  5. Copy aerolqrrsp.mat to your own folder and rename it as nocouple_pitch_only.

  6. Examine the obtained closed-loop response and see if it matches the desired specifications.

Yaw Command Only

  1. Use a yaw command (45 deg) only by changing Amp_p to zero.

  2. Run SIMULINK

  3. Copy aero_lqr_rsp.mat to your own folder and rename it as nocouple_yaw_only.

  4. Examine the obtained closed-loop response and see if it matches the desired specifications

Both Yaw and Pitch

  1. Use both pitch and yaw command

  2. Run SIMULINK

  3. Copy aerolqrrsp.mat to your own folder and rename it as nocouple_pitch_yaw.

  4. Examine the obtained closed-loop response and see if it matches the desired specifications

With Coupling Effect

  1. Use the gain KKKobtained in Part B. with the coupling effect.

  2. Repeat above Pitch Only, Yaw Only and both Yaw and Pitch runs and rename the files as couple_####_###.

  3. Close the Simulink. DO NOT SAVE THE CHANGE!

Analysis Question

  1. Did your controller successfully meet the specs? If not, why?

  2. How does the coupling affect the performance of the controller?

  3. How can we improve the controller?

PreviousA. System Identification (Week 1) last checkNextRotary Gyro

Last updated 2 years ago

Was this helpful?

To build the model, click the down arrow on Monitor & Tune under the Hardware tab and then click Build for monitoring . This generates the controller code.

Click Connect button under Monitor & Tune and then run SIMULINK by clicking Start .

22KB
q_aero_2dof_lqr_control.slx
Fig. 11: Model used to acquire free-oscillation response about pitch
Fig. 12: SIMULINK model used to run LQR controller