model predictive control on an fpga aerospace and space
play

Model Predictive Control on an FPGA: Aerospace and Space Scenarios - PowerPoint PPT Presentation

Model Predictive Control on an FPGA: Aerospace and Space Scenarios Edward Hartley ( edward.hartley@eng.cam.ac.uk ) Workshop on Embedded Optimisation EMBOPT 2014, IMT Lucca Monday 8th September 2014: 14:0015:00 Cambridge University Engineering


  1. Model Predictive Control on an FPGA: Aerospace and Space Scenarios Edward Hartley ( edward.hartley@eng.cam.ac.uk ) Workshop on Embedded Optimisation EMBOPT 2014, IMT Lucca Monday 8th September 2014: 14:00–15:00 Cambridge University Engineering Department

  2. Introduction 1. What is MPC? (You probably already know) What is an FPGA? 2. Interior point QP-based MPC on an FPGA, for aircraft control 3. Interior point LP-based VH-LTV-MPC on an FPGA, for medium-range spacecraft rendezvous 4. First-order QP-based MPC on an FPGA, for terminal spacecraft rendezvous 5. Conclusions and lessons learnt 2/44

  3. Introduction Model Predictive Control Prediction Objective Constraints model function “Setup” Disturbances Optimal Optimisation control Plant algorithm problem Observer (KF) “Online tasks” “Real world” 3/44

  4. Introduction Model Predictive Control Prediction Objective Constraints model function “Setup” Disturbances Optimal Optimisation control Plant algorithm problem Observer (KF) “Online tasks” “Real world” 3/44

  5. Introduction Field Programmable Gate Array • F ield P rogrammable G ate A rray • Programmable hardware • Contains many logic blocks: Lookup tables, Flip-flops, RAM, Dedicated Multipliers • User specifies how these should be connected together • Implementing a circuit for an algorithm on an FPGA is not like programming a microprocessor • Multiple clocks • Parallelism • Timing • Custom numerical representations 4/44

  6. Introduction . . . and what’s this got to do with MPC? Raw speed • Exploit parallelism • Make the controller latency ever lower • Control fast processes Latency vs. clock rate • Achieve controller latency similar to running MPC on a desktop PC, but on embedded hardware at much lower clock rates Embeddability • System on a chip • Power consumption advantages? 5/44

  7. Introduction . . . and what’s this got to do with MPC? Raw speed • Exploit parallelism • Make the controller latency ever lower • Control fast processes Latency vs. clock rate • Achieve controller latency similar to running MPC on a desktop PC, but on embedded hardware at much lower clock rates Embeddability • System on a chip • Power consumption advantages? 5/44

  8. Aerospace Application Scenario Description y r ( t ) x ∞ ( t ) u ∞ ( t ) y ( t ) Target Calc MPC Observer x ( t | t − T s ) , ˆ ˆ ξ ( t | t − T s ) Control Objective • MPC: Control roll and pitch of B747 • Use all actuators and all state measurements • Outer loop provides roll/pitch setpoints to track altitude/yaw trajectory 6/44

  9. Aerospace Application Plant description MIMO aircraft control • 12 states: • Roll rate, Pitch rate, Yaw Rate • Airspeed, AoA, Sideslip • Roll, Pitch • 4 engine dynamics (1st order lag) • 17 inputs: • 4 elevators, 1 trimmable horizontal stabiliser • 4 ailerons, 2 spoiler banks • 2 rudders • 4 engine setpoints • 34 contraints: Upper/lower bound on each input 7/44

  10. Aerospace Application MPC description Why MPC ... on an FPGA? • Embeddability • Multivariable control • Latency vs clock rate • Contraints • Reconfiguration (not addressed here) MPC parameters • Quadratic cost • Tracking • No state constraints • Prediction horizon N = 5 or N = 12 • Uncondensed formulation (sparse with equality constraints) 8/44

  11. Aerospace Application MPC formulation Finite horizon OCP N − 1 � θ � δ x N − δ x s � 2 � � δ x i − δ x s � 2 Q + � δ u i − δ u s � 2 � P + (1a) min R i = 0 subject to: δ x 0 = δ ˆ x ( k ) (1b) δ x i + 1 = A δ x i + B δ u i + B d ˆ w ( k ) , i = 0 , . . . , N − 1 (1c) δ u min ≤ δ u i ≤ δ u max , i = 0 , . . . , N − 1 . (1d) • (The δ indicates deviation from trim point used for linearisation) • � · � 2 X � · T X · 9/44

  12. Aerospace Application QP formulation OCP as a QP 1 2 θ T H θ + h T θ subject to G θ ≤ g , F θ = f . min θ where. . . H � 2 ( I N ⊗ ( Q ⊕ R )) ⊕ P � � � � 0 m × n I m G � I N ⊗ , 0 2 Nm × n 0 m × n − I m − I n   A B − I n • ⊕ : Direct sum   F � .  ...  .   • ⊗ : Kronecker product .   − I n h � − 1 T − δ x T � T � � δ x T δ u T � N ⊗ ∞ Q ∞ R ∞ P � T g � 1 N ⊗ � δ u T − δ u T max min � T . f � x T ( k ) − ( 1 T w T ( k ) B T � − ˆ N ⊗ ˆ d ) 10/44

  13. Aerospace Application Primal-Dual Interior Point Method Initialisation Critical path Compute residuals Linearise relaxed KKT + block elimination Solve linear system Update iterate yes no k ≤ k max ? Stop 11/44

  14. Aerospace Application Solving the Linear System Computational bottleneck Conventional approach ✛ Factorise + substitute � H + Φ k � � ∆ θ k � � Many divisions F T = b k ∆ ν k F 0 � Cannot terminate early � �� � � Difficult to parallelise A k Alternative approach applied ✛ Solve using iterative MINRES (Minimum Residual) algorithm � Iterations vs accuracy � Sensitive to conditioning � Matrix-vector multiplication: � Sensitive to precision very parallelisable � Inefficient without � Sparse structure (and most parallelisation elements do not change) 12/44

  15. Aerospace Application Problem Scaling • Linear system conditioning important • Diagonal online preconditioner • Offline model scaling : Consider the substitution A ← T Q AT − 1 B ← T Q BT − 1 Q R Q ← T − 1 Q QT − 1 R ← T − 1 R RT − 1 Q R P ← T − 1 Q PT − 1 Q for diagonal T Q > 0 and T R > 0 , and corresponding scalings on the constraints. Choose T Q , T R to approximately normalise the 2-norms of the rows of � H + ✚ F T � ❩ Φ k ✚ ❩ F 0 (Heuristic, but effective) 13/44

  16. Aerospace Application Problem Scaling: importance 5 5 10 160 10 160 140 140 Max rel err 120 120 Mean rel err Mean cost Quality metric 100 Quality metric 100 Solution time Time (ms) Time (ms) 0 0 10 80 10 80 60 60 40 40 20 20 −5 −5 10 0 10 0 10 100 516 1000 10 100 516 1000 MINRES iterations per PDIP iteration MINRES iterations per PDIP iteration (a) No preconditioning (b) Online preconditioning only • Based on closed-loop simulation in software • Timing estimate for 250 MHz FPGA based on analytical formula • Without preconditioning, MINRES-based solver is disastrous • With online preconditioning good results if enough MINRES iterations per PDIP iteration 14/44

  17. Aerospace Application Problem Scaling: importance 5 5 10 160 10 160 140 140 120 120 Quality metric 100 Quality metric 100 Time (ms) Time (ms) 0 0 10 80 10 80 60 60 40 40 20 20 −5 −5 10 0 10 0 10 100 516 1000 10 100 516 1000 MINRES iterations per PDIP iteration MINRES iterations per PDIP iteration (c) Offline preconditioning only (d) Online & Offline Preconditioning • With offline preconditioning, solution quality for low MINRES iteration counts improves • Best results with both offline and online preconditioning 15/44

  18. Aerospace Application Implementation details General Implementation • Pure VHDL solver coded by Juan Jerez (Imperial, now ETH). • Prediction model hard coded in ROM. • Connect to MicroBlaze for HIL setup • Software server on MicroBlaze enables communication over ethernet with plant model in Simulink, using UDP/IP 16/44

  19. Aerospace Application Hardware-in-the-loop Setup Target calculator QP Solver Sequential stage • Nonlinear Plant Micro- UDP/IP • Observer blaze • Reference Traj. Ether- Ether- AXI Server net net Parallel 100 Mbit Bus code PHY MAC MINRES Ethernet lwip accelerator Simulink . . . Virtex 6 LX240T Desktop/Laptop Computer ML605 Evaluation Board 17/44

  20. Aerospace Application Computation time comparison Implementation Relative numerical accuracy Mean Max Solution time QP Solver Bits cost QP (ms) Clock cycles N I MR e max e µ 9 . 67 × 10 − 4 3 . 02 × 10 − 5 F /P-MINRES 32 12 5 . 2246 2 . 89 × 10 6 51 12 5 . 59 × 10 7 PC/RWR1998 64 12 – – – 5 . 2247 23 5 . 89 × 10 − 3 1 . 69 × 10 − 4 3 . 09 × 10 7 PC/FORCES 64 12 – 5 . 2250 13 3 . 83 × 10 − 3 7 . 31 × 10 − 5 1 . 91 × 10 8 UB/FORCES 32 12 – 5 . 2249 1911 9 . 10 × 10 − 4 2 . 95 × 10 − 5 1 . 09 × 10 6 F /P-MINRES 32 5 30 5 . 2203 4 PC/RWR1998 64 5 – – – 11 2 . 64 × 10 7 5 . 2204 1 . 04 × 10 − 3 1 . 84 × 10 − 5 PC/CVXGEN 64 5 – 7 . 20 × 10 6 5 . 2203 3 5 . 00 × 10 − 3 1 . 24 × 10 − 4 1 . 44 × 10 7 PC/FORCES 64 5 – 5 . 2207 6 ( 2 . 69 × 10 7 ) UB/CVXGEN 32 5 – ?? ?? ?? ( 269 ) 4 . 14 × 10 − 3 8 . 01 × 10 − 5 8 . 23 × 10 7 UB/FORCES 32 5 – 5 . 2205 823 (FPGA QP solver (F) running at 250 MHz , PC (PC) at 2 . 4 GHz and MicroBlaze (UB) at 100 MHz . (–) indicates a baseline. (??) indicates that meaningful data for control could not be obtained). P-MINRES indicates preconditioned MINRES. RWR1998 indicates Rao-Wright-Rawlings-Riccati-Recursion. 18/44

Recommend


More recommend