The Inverted Pendulum

Similar documents
Review: control, feedback, etc. Today s topic: state-space models of systems; linearization

P321(b), Assignement 1

In the presence of viscous damping, a more generalized form of the Lagrange s equation of motion can be written as

28. Pendulum phase portrait Draw the phase portrait for the pendulum (supported by an inextensible rod)

M2A2 Problem Sheet 3 - Hamiltonian Mechanics

Stability of Nonlinear Systems An Introduction

Quadratic Stability of Dynamical Systems. Raktim Bhattacharya Aerospace Engineering, Texas A&M University

Swinging-Up and Stabilization Control Based on Natural Frequency for Pendulum Systems

OPTIMAL CONTROL. Sadegh Bolouki. Lecture slides for ECE 515. University of Illinois, Urbana-Champaign. Fall S. Bolouki (UIUC) 1 / 28

Linear control of inverted pendulum

Numerics and Control of PDEs Lecture 1. IFCAM IISc Bangalore

Torque and Simple Harmonic Motion

Classical Mechanics Comprehensive Exam Solution

System simulation using Matlab, state plane plots

EE Homework 3 Due Date: 03 / 30 / Spring 2015

HW 6 Mathematics 503, Mathematical Modeling, CSUF, June 24, 2007

Dynamical Systems & Lyapunov Stability

Lagrange s Equations of Motion and the Generalized Inertia

Feedback Optimal Control for Inverted Pendulum Problem by Using the Generating Function Technique

Lecture 9 Nonlinear Control Design

CHAPTER 1. Introduction

ROTATIONAL DOUBLE INVERTED PENDULUM

Time- and Energy-Based Stability

Analytical Mechanics: Variational Principles

Consider a particle in 1D at position x(t), subject to a force F (x), so that mẍ = F (x). Define the kinetic energy to be.

PHYS2330 Intermediate Mechanics Fall Final Exam Tuesday, 21 Dec 2010

Robotics. Control Theory. Marc Toussaint U Stuttgart

Topic # /31 Feedback Control Systems. Analysis of Nonlinear Systems Lyapunov Stability Analysis

Lecture 4 Continuous time linear quadratic regulator

Robot Control Basics CS 685

Oscillating Inverted Pendulum and Applications

Lecture 19: Calculus of Variations II - Lagrangian

7 Pendulum. Part II: More complicated situations

System Control Engineering

EE C128 / ME C134 Final Exam Fall 2014

Lab 6a: Pole Placement for the Inverted Pendulum

Columbia University Department of Physics QUALIFYING EXAMINATION

Optimal Control. McGill COMP 765 Oct 3 rd, 2017

A. B. C. D. E. v x. ΣF x

Examination paper for TMA4195 Mathematical Modeling

Assignments VIII and IX, PHYS 301 (Classical Mechanics) Spring 2014 Due 3/21/14 at start of class

EN Applied Optimal Control Lecture 8: Dynamic Programming October 10, 2018

ECEN 420 LINEAR CONTROL SYSTEMS. Lecture 6 Mathematical Representation of Physical Systems II 1/67

EE 16B Midterm 2, March 21, Name: SID #: Discussion Section and TA: Lab Section and TA: Name of left neighbor: Name of right neighbor:

CIMPA Summer School on Current Research on Finite Element Method Lecture 1. IIT Bombay. Introduction to feedback stabilization

Physics 235 Chapter 7. Chapter 7 Hamilton's Principle - Lagrangian and Hamiltonian Dynamics

The Principle of Least Action

2 We alsohave a second constant of the motion, the energy, H = 2 (M + m) _X 2 +mr cos # _X _ #+ 2 mr2 _ # 2 mgr cos # = constant : For small displacem

Lyapunov stability ORDINARY DIFFERENTIAL EQUATIONS

Classical Dynamics: Question Sheet

Lecture 9 Nonlinear Control Design. Course Outline. Exact linearization: example [one-link robot] Exact Feedback Linearization

Classical Mechanics Review (Louisiana State University Qualifier Exam)

Question 1: A particle starts at rest and moves along a cycloid whose equation is. 2ay y a

MATH4406 (Control Theory) Unit 6: The Linear Quadratic Regulator (LQR) and Model Predictive Control (MPC) Prepared by Yoni Nazarathy, Artem

CP1 REVISION LECTURE 3 INTRODUCTION TO CLASSICAL MECHANICS. Prof. N. Harnew University of Oxford TT 2017

Fundamentals Physics. Chapter 15 Oscillations

EE363 homework 2 solutions

Modeling and Experimentation: Compound Pendulum

3 Space curvilinear motion, motion in non-inertial frames

State Regulator. Advanced Control. design of controllers using pole placement and LQ design rules

Different Modelling and Controlling Technique For Stabilization Of Inverted Pendulam

Optimal Control. Lecture 18. Hamilton-Jacobi-Bellman Equation, Cont. John T. Wen. March 29, Ref: Bryson & Ho Chapter 4.

Linear Quadratic Regulator (LQR) Design I

Linear Quadratic Regulator (LQR) I

Linearization problem. The simplest example

Lecture Note 1: Background

Lecture 2 and 3: Controllability of DT-LTI systems

Chapter 14 Periodic Motion

Rotational motion problems

Simple and Physical Pendulums Challenge Problem Solutions

STABILITY. Phase portraits and local stability

moments of inertia at the center of gravity (C.G.) of the first and second pendulums are I 1 and I 2, respectively. Fig. 1. Double inverted pendulum T

Non-Linear Response of Test Mass to External Forces and Arbitrary Motion of Suspension Point

= v 0 x. / t = 1.75m / s 2.25s = 0.778m / s 2 nd law taking left as positive. net. F x ! F

This module requires you to read a textbook such as Fowles and Cassiday on material relevant to the following topics.

Math Ordinary Differential Equations

Physics 141 Energy 1 Page 1. Energy 1

Stabilization and Passivity-Based Control

Unforced Oscillations

CDS 101/110a: Lecture 2.1 Dynamic Behavior

Hamiltonian. March 30, 2013

Chaos Theory. Namit Anand Y Integrated M.Sc.( ) Under the guidance of. Prof. S.C. Phatak. Center for Excellence in Basic Sciences

Chapter 5 Oscillatory Motion

Optimal Control. Quadratic Functions. Single variable quadratic function: Multi-variable quadratic function:

Physics Mechanics. Lecture 32 Oscillations II

Physics 5A Final Review Solutions

CHAPTER 12 OSCILLATORY MOTION

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Physics Department 8.01 Physics I Fall Term 2009 Review Module on Solving N equations in N unknowns

EQUIVALENT SINGLE-DEGREE-OF-FREEDOM SYSTEM AND FREE VIBRATION

Variation Principle in Mechanics

SOLUTIONS, PROBLEM SET 11

6. Linear Quadratic Regulator Control

THE LAGRANGIAN AND HAMILTONIAN MECHANICAL SYSTEMS

Tutorial-1, MA 108 (Linear Algebra)

Physics H7A, Fall 2011 Homework 6 Solutions

kx m x B N 1 C L, M Mg θ

The Acrobot and Cart-Pole

Physics 200 Lecture 4. Integration. Lecture 4. Physics 200 Laboratory

OSCILLATIONS ABOUT EQUILIBRIUM

1 Lyapunov theory of stability

Transcription:

Lab 1 The Inverted Pendulum Lab Objective: We will set up the LQR optimal control problem for the inverted pendulum and compute the solution numerically. Think back to your childhood days when, for entertainment purposes, you d balance objects: a book on your head, a spoon on your nose, or even a broom on your hand. Learning how to walk was likely your initial introduction to the inverted pendulum problem. A pendulum has two rest points: a stable rest point directly underneath the pivot point of the pendulum, and an unstable rest point directly above. The generic pendulum problem is to simply describe the dynamics of the object on the pendulum (called the bob ). The inverted pendulum problem seeks to guide the bob toward the unstable fixed point at the top of the pendulum. Since the fixed point is unstable, the bob must be balanced relentlessly to keep it upright. The inverted pendulum is an important classical problem in dynamics and control theory, and is often used to test different control strategies. One application of the inverted pendulum is the guidance of rockets and missiles. Aerodynamic instability occurs because the center of mass of the rocket is not the same as the center of drag. Small gusts of wind or variations in thrust require constant attention to the orientation of the rocket. The Simple Pendulum We begin by studying the simple pendulum setting. Suppose we have a pendulum consisting of a bob with mass m rotating about a pivot point at the end of a (massless) rod of length l. Let θ(t) represent the angular displacement of the bob from its stable equilibrium. By Hamilton s Principle, the path θ that is taken by the bob minimizes the functional J[θ] = t1 t 0 L, (1.1) where the Lagrangian L = T U is the difference between the kinetic and potential energies of the bob. 3

4 Lab 1. The Inverted Pendulum Figure 1.1: The frame of reference for the simple pendulum problem. The kinetic energy of the bob is given by mv 2 /2, where v is the velocity of the bob. In terms of θ, the kinetic energy becomes T = m 2 v2 = m 2 (ẋ2 +ẏ 2 ), = m 2 ((l cos(θ) θ) 2 +(l sin(θ) θ) 2 ), 2 ml2 θ =. 2 (1.2) The potential energy of the bob is U = mg(l l cos θ). From these expressions we can form the Euler-Lagrange equation, which determines the path of the bob: 0=L θ d dx L θ, = mgl sin θ ml 2 θ, (1.3) = θ + g l sin θ. Since in this setting the energy of the pendulum is conserved, the equilibrium position θ = 0 is only Lyapunov stable. When forces such as friction and air drag are considered θ = 0 becomes an asymptotically stable equilibrium. The Inverted Pendulum The Control System We consider a gift suspended above a rickshaw by a (massless) rod of length l. The rickshaw and its suspended gift will have masses M and m respectively, M>

5 Figure 1.2: The inverted pendulum problem on a mobile rickshaw with a present suspended above. m. Let θ represent the angle between the gift and its unstable equilibrium, with counterclockwise orientation. Let v 1 and v 2 represent the velocities of the rickshaw and the gift, and F the force exerted on the rickshaw. The rickshaw will be restricted to traveling along a straight line (the x-axis). By Hamilton s Principle, the path (x, θ) of the rickshaw and the present minimizes the functional J[x, θ] = t1 t 0 L, (1.4) where the Lagrangian L = T U is the difference between the kinetic energy of the present on the pendulum, and its potential energy. Since the position of the rickshaw and the present are (x(t), 0) and (x l sin θ, l cos θ) respectively, the total kinetic energy is T = 1 2 Mv2 1 + 1 2 mv2 2, = 1 2 Mẋ2 + 1 2 m((ẋ l θ cos θ) 2 +( l θ sin θ) 2 ), (1.5) The total potential energy is =ẋ 2 + l 2 θ2 2lẋ θ cos θ. U = mgl cos θ Fx. Since the path (x, θ) of the rickshaw and the present satisfy the Euler-Lagrange

6 Lab 1. The Inverted Pendulum differential equations L x d L dt ẋ =0, L θ d L =0, dt θ after expanding (1.6) we see that x(t) and θ(t) satisfy F =(M + m)ẍ ml θ cos θ + ml θ 2 sin θ, l θ = g sin θ +ẍ cos θ. (1.6) (1.7) At this point we make a further simplifying assumption. If θ starts close to 0, we may assume that the corresponding force F will keep θ small. In this case, we linearize (1.7) about (θ, θ) =(0, 0), obtaining the equations F =(M + m)ẍ ml θ, l θ = gθ +ẍ. These equations can be further manipulated to obtain ẍ = 1 M F m M gθ, θ = 1 Ml F + g Ml (M + m)θ. (1.8) We will now write (1.8) as a first order system. Making the assignments x 1 = x, x 2 = x 1, θ 1 = θ, θ 2 = θ 1,lettingu = F represent the control variable, we obtain x 1 0 1 0 0 x 1 0 x 2 mg θ 1 = 0 0 M 0 x 2 0 0 0 1 θ 1 + u 1, θ 2 0 0 (M + m) 0 θ 2 g Ml which can be written more concisely as z = Az + Bu. M 0 1 Ml Problem 1. Write a function that returns the matrices A, B, Q, and R given above. Let g =9.8 m/s 2. def linearized_init(m, m, l, q1, q2, q3, q4, r): Parameters: ---------- M, m: floats masses of the rickshaw and the present l : float length of the rod q1, q2, q3, q4, r : floats relative weights of the position and velocity of the rickshaw, the angular displacement theta and the change in theta, and the

7 control Return ------- A : ndarray of shape (4,4) B : ndarray of shape (4,1) Q : ndarray of shape (4,4) R : ndarray of shape (1,1) pass The infinite time horizon LQR problem We consider the cost function J[z] = = 0 0 (q 1 x 2 1 + q 2 x 2 2 + q 3 θ 2 1 + q 4 θ 2 2 + ru 2 ) dt z T Qz + u T Ru dt where q 1,q 2,q 3,q 4, and r are nonnegative weights, and q 1 0 0 0 Q = 0 q 2 0 0 0 0 q 3 0,R= [ r ]. 0 0 0 q 4 (1.9) The optimal control problem (1.9) is an example of a Linear Quadratic Regulator (LQR), and is known to have an optimal control ũ described by a linear state feedback law: ũ = R 1 B T P z. Here P is a matrix function that satisfies the Riccati differential equation (RDE) P (t) =PA+ A T P + Q PBR 1 B T P. Since this problem has an infinite time horizon, we have P = 0. Thus P is a constant matrix, and can be found by solving the algebraic Riccati equation (ARE) PA+ A T P + Q PBR 1 B T P =0. (1.10) The evolution of the optimal state vector z can then be described by 1 z =(A BR 1 B T P ) z. (1.11) 1 See Calculus of Variations and Optimal Control Theory, Daniel Liberzon, Ch.6

8 Lab 1. The Inverted Pendulum Problem 2. Write the following function to find the matrix P. Use scipy. optimize.root. Since root takes in a vector and not a matrix, you will have to reshape the matrix P before passing it in and after getting your result, using np.reshape(16) and np.reshape((4,4)). def find_p(a,b,q,r): Parameters: ---------- A, B, Q : ndarrays of shape (4,4) R : ndarray of shape (1,1) Returns ------- P pass : the matrix solution of the Riccati equation Using the values M, m = 23., 5. l = 4. q1, q2, q3, q4 = 1., 1., 1., 1. r = 5. compute the eigenvalues of A BR 1 B T P. Are any of the eigenvalues positive? Consider differential equation (1.11) governing the optimal state z. Using this value of P, will we necessarily have z 0? Notice that we have no information on how many solutions (1.10) possesses. In general there may be many solutions. We hope to find a unique solution P that is stabilizing: the eigenvalues of A BR 1 B T P have negative real part. To find this P, use the function solve_continuous_are from scipy.linalg. This function is designed to solve the continuous algebraic Riccati equation. Problem 3. Write the following function that implements the LQR solution described earlier. For the IVP solver, you can use your own or you may use the function ode from scipy.integrate. def rickshaw(tv,x0,a, B, Q, R_inv, P): Parameters: ---------- tv : ndarray of time values, with shape (n+1,) X0 : A, B, Q : ndarrays of shape (4,4) R_inv : ndarray of shape (1,1), inverse of R P : ndarray of shape (4,4) Returns

9 P is found using scipy.optimize.root. P is found using solve_continuous_are. Figure 1.3: The solutions of Problem 4. ------- Z : ndarray of shape (n+1,4), the state vector at each time U : ndarray of shape (n,), the control values Problem 4. Test the function made in Problem (3) with the following inputs: M, m = 23., 5. l = 4. q1, q2, q3, q4 = 1., 1., 1., 1. r = 10. tf = 15 X0 = np.array([-1, -1,.1, -.2]) Use both scipy.optimize.root and solve_continuous_are to find the matrix P. Compare your results. The results are plotted in Figure 1.3. Problem 5. Consider the following inputs: M, m = 23., 5. l = 4. q1, q2, q3, q4 = 1., 1., 1., 1. r = 10. tf = 60 X0 = np.array([-1, -1,.1, -.2]) Vary the entries of X0 responsible for θ(0) and θ(0) to determine the sensitivity

10 Lab 1. The Inverted Pendulum of the control u to the initial conditions. What initial conditions lead to a reasonable, physical control u?