ABSTRACT Title of Thesis: LIMITATIONS OF NONLINEAR CONTROLS FOR A CURVED AND OFFSET BEAM AND BALL Brandon Au, Master?s of Science, 2013 Master?s Thesis directed by: Professor William Levine Department of Electrical and Computer Engineering The problem of stabilizing the position of a ball on a straight beam is a common element of laboratory courses in control. Replacing the straight beam with a circular beam and moving the center of rotation o of the beam produces a harder control problem. This experiment was developed here at UMCP by Sheng, Renner, and Levine [1]. They designed and implemented a stabilizing controller based on a linearized model of the plant and an LQR optimal regulator. Here, the set of initial states that is stabilizable is explored. Also, nonlinear controls based on ideas from feedback linearization and backstepping are developed. LIMITATIONS OF NONLINEAR CONTROLS FOR A CURVED AND OFFSET BEAM AND BALL by Brandon Au Thesis submitted to the Faculty of the Graduate School of the University of Maryland, College Park in partial ful llment of the requirements for the degree of Master?s of Science 2013 Defense Committee: Dr. William Levine, Chair/Advisor Dr. Andre Tits Dr. Gilmer Blankenship c Copyright by Brandon Au 2013 Table of Contents List of Figures iv 1 Introduction 1 1.1 Model of Straight Beam and Ball . . . . . . . . . . . . . . . . . . . . 2 1.2 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 The Model 4 2.1 Derivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.2 Force of Interaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.3 Dimensionless Parameters . . . . . . . . . . . . . . . . . . . . . . . . 7 2.4 Linearized Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.5 Motor Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.6 Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3 Parametric Studies 11 3.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.2 Initial Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 3.3 Case d = 0:5m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.4 Case d = 0:375m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 3.5 Case d = 0:75m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 3.6 Case d = 1:5m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.7 Case d = 7:5m . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 3.8 Causes for Ball Leaving the Beam . . . . . . . . . . . . . . . . . . . . 34 4 Nonlinear Controls 38 4.1 Feedback Linearization . . . . . . . . . . . . . . . . . . . . . . . . . . 38 4.2 Lyapunov Studies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 5 New Coordinate System 43 5.1 Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 6 Conclusion 50 ii Bibliography 51 iii List of Figures 1.1 An abstract straight beam and ball setup . . . . . . . . . . . . . . . . 1 2.1 The Curved Beam and Ball Model . . . . . . . . . . . . . . . . . . . 4 3.1 Linear Model Simulation, d = 0:5m, Initial condition [0.1, 0.1, 0.1, 0.1] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.2 Nonlinear Model Simulation, d = 0:5m, Initial condition [0.1, 0.1, 0.1, 0.1] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.3 Di erence in Nonlinear and Linear Model Simulations, d = 0:5m, Initial condition [0.1, 0.1, 0.1, 0.1] . . . . . . . . . . . . . . . . . . . 13 3.4 Linear Model Simulation, d = 0:5m, Initial condition [0, 0, 0, 0.3] . . 14 3.5 Nonlinear Model Simulation, d = 0:5m, Initial condition [0, 0, 0, 0.3] 14 3.6 Linear Model Simulation, d = 0:5m, Initial condition [0, 0, 0.172, 0] . 15 3.7 Nonlinear Model Simulation, d = 0:5m, Initial condition [0, 0, 0.172, 0] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.8 Di erence in Nonlinear and Linear Model Simulations, d = 0:5m, Initial condition [0, 0, 0.172, 0] . . . . . . . . . . . . . . . . . . . . . 16 3.9 Unstable Nonlinear Model Simulation, d = 0:5m, Initial condition [0, 0, 0.173, 0] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3.10 States of System initially ( = 0 and = 0:172) and when ball leaves ( = 0:226 and = 0:257) for d = 0:5m . . . . . . . . . . . . . . . . 17 3.11 Input Signal for Nonlinear Model Simulation, d = 0:5m, Initial con- dition [0, 0, 0.172, 0] . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 3.12 Linear Model Simulation, d = 0:375m, Initial condition [0, 0, 0.150, 0] 19 3.13 Nonlinear Model Simulation, d = 0:375m, Initial condition [0, 0, 0.150, 0] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.14 Di erence in Nonlinear and Linear Model Simulations, d = 0:375m, Initial condition [0, 0, 0.150, 0] . . . . . . . . . . . . . . . . . . . . . 20 3.15 Unstable Nonlinear Model Simulation, d = 0:375m, Initial condition [0, 0, 0.151, 0] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 3.16 States of System initially ( = 0 and = 0:150) and when ball leaves ( = 0:349 and = 0:339) for d = 0:375m . . . . . . . . . . . . . . . 21 iv 3.17 Input Signal for Nonlinear Model Simulation, d = 0:375, Initial con- dition [0, 0, 0.150, 0] . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 3.18 Linear Model Simulation, d = 0:75m, Initial condition [0, 0, 0.171, 0] 22 3.19 Nonlinear Model Simulation, d = 0:75m, Initial condition [0, 0, 0.171, 0] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.20 Di erence in Nonlinear and Linear Model Simulations, d = 0:75m, Initial condition [0, 0, 0.171, 0] . . . . . . . . . . . . . . . . . . . . . 23 3.21 Unstable Nonlinear Model Simulation, d = 0:75m, Initial condition [0, 0, 0.172, 0] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.22 States of System initially ( = 0 and = 0:171) and when ball leaves ( = 0:045 and = 0:172) for d = 0:75m . . . . . . . . . . . . . . . . 24 3.23 Input Signal for Nonlinear Model Simulation, d = 0:75m, Initial con- dition [0, 0, 0.171, 0] . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.24 Linear Model Simulation, d = 1:5m, Initial condition [0, 0, 0.187, 0] . 26 3.25 Nonlinear Model Simulation, d = 1:5m, Initial condition [0, 0, 0.187, 0] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.26 Di erence in Nonlinear and Linear Model Simulations, d = 1:5m, Initial condition [0, 0, 0.187, 0] . . . . . . . . . . . . . . . . . . . . . 27 3.27 Unstable Nonlinear Model Simulation, d = 1:5m, Initial condition [0, 0, 0.188, 0] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 3.28 States of System initially ( = 0 and = 0:187) and when ball leaves ( = 0:014 and = 0:175) for d = 1:5m . . . . . . . . . . . . . . . . 28 3.29 Input Signal for Nonlinear Model Simulation, d = 1:5m, Initial con- dition [0, 0, 0.187, 0] . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 3.30 Linear Model Simulation, d = 7:5m, Initial condition [0, 0, 0.463, 0] . 29 3.31 Nonlinear Model Simulation, d = 7:5m, Initial condition [0, 0, 0.463, 0] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 3.32 Di erence in Nonlinear and Linear Model Simulations, d = 7:5m, Initial condition [0, 0, 0.463, 0] . . . . . . . . . . . . . . . . . . . . . 30 3.33 Unstable Nonlinear Model Simulation, d = 7:5m, Initial condition [0, 0, 0.464, 0] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 3.34 States of System initially ( = 0 and = 0:463) and when ball leaves ( = 0:004 and = 0:436) for d = 7:5m . . . . . . . . . . . . . . . . 32 3.35 Input Signal for Nonlinear Model Simulation, d = 7:5m, Initial con- dition [0, 0, 0.463, 0] . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 3.36 Max 0 value vs d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 3.37 Max 0 vs d . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 4.1 Plot of the max initial phi value vs pivot distance when altering the Q in LQR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 5.1 New Coordinate System . . . . . . . . . . . . . . . . . . . . . . . . . 43 5.2 New Coordinate System- Linear Model Simulation, d = 0:5, Initial condition [0.626, 0, 0, 0] . . . . . . . . . . . . . . . . . . . . . . . . . 47 v 5.3 New Coordinate System- Nonlinear Model Simulation, d = 0:5, Initial condition [0.626, 0, 0, 0] . . . . . . . . . . . . . . . . . . . . . . . . . 47 5.4 New Coordinate System- Di erence in Nonlinear and Linear Model Simulations, d = 0:5, Initial condition [0.626, 0, 0, 0] . . . . . . . . . 48 5.5 New Coordinate System- Unstable Nonlinear Model Simulation, d = 0:5, Initial condition [0.627, 0, 0, 0] . . . . . . . . . . . . . . . . . . . 48 vi Chapter 1: Introduction The ball and straight beam is widely used in many control labs as an example of a system that is relatively easy to understand and model but challenging to control. There are many publications concerning various control implementations of di ering apparatuses and models. There are two typical constructions of the model. One model places the center of the motor shaft at the center of the pivot, while the other places the pivot at one end of the beam. While the model calculations are slightly di erent, the complexity is similar. Figure 1.1: The motor rotates the beam, and value of is a possible equilibrium point when = 0. The ball rolls under the in uence of gravity. 1 1.1 Model of Straight Beam and Ball The two typical states that are measurable are the position of the ball and the angle of the beam. The dynamics for the model in Fig. 1.1 is as follows [1] 0 = m +mg sin m _ 2 Q = (m 2 + Ib) + 2m _ _ + (mg +Mgr) cos ( ) where m is the mass of the ball, M is the mass of the beam, g is the acceleration of gravity, Ib is the inertia of the beam about the pivot, r is the distance from the pivot to the center of the beam, is the beam angle, is the ball position, and Q is the torque applied by the motor. If the pivot is located at the center of the beam, so r = 0, then the Mgr cos ( ) term disappears. The rotation of the ball is omitted, as its e ect is small relative to the system dynamics. 1.2 Background In this thesis, we expand and correct the related system described by Sheng, Renner, and Levine [1]. We also compare the nonlinear and linear performances, and results from tests using nonlinear control theories. The straight beam and ball setup is replaced with a circular beam and the pivot is not on the beam but o set to a point below the beam, as shown in Fig 2.1. The ball and circular beam setup as described by Sheng et al. [1] considered only the linearized system and its performance using linear controls. No testing was done using the nonlinear model, which could allow for other equilibrium points 2 besides the origin. The nonlinear model should also provide more accurate simula- tions. However, the model and equations needed corrections, which are done in this paper. The same setup is used, with the system being linearized about a beam angle = 0 so that the pivot and center of the circle are on a common vertical line. The system is simpli ed by making the ball very light compared to the beam, allowing the ball dynamics (the rotation) to be very small compared to the dynamics of the beam. This linear control input is then implemented in the nonlinear model for simulations, and the results are discussed later. In Khalil [2], feedback linearization of a nonlinear model is described to trans- form the nonlinear system into a linear one using an appropriate transformation of the states and new control input. Hauser, et al. [3] then describes some approxi- mate input-output linearizations of a nonlinear system (the straight beam and ball) that can be used should feedback linearization be unfeasible. However, feedback lin- earization would be better because approximate input-output linearizations would remove or simplify terms, thus limiting the accuracy of the model. A new coordi- nate system of the same ball and beam setup may make the possibility of feedback linearization obvious, while another may not. Thus, a new coordinate system is also considered. 3 Chapter 2: The Model 2.1 Derivation Figure 2.1: The coordinate system used for derivation [1]. The y direc- tion is vertical (aligned with gravity) Following [1] but correcting a number of errors, consider the system shown in Fig. 2.1, where the beam is an arc of a circle of radius r and d is the distance between the center of the motor shaft and the center of the beam circle. The x, y positions and velocities of the ball are given as x = r sin ( ) + d sin ( ) (2.1) y = r cos ( ) d cos ( ) (2.2) 4 _x = r cos ( )( _ _ ) + d cos ( ) _ (2.3) _y = r sin ( )( _ _ ) + d sin ( ) _ (2.4) where (x; y) is the current position of the ball. The kinetic energy of the system, T (ignoring the small amount of energy in the rotation of the ball), is T = 1 2 m( _x2 + _y2) + 1 2 Ib _ 2 (2.5) The ball contributes a potential energy V = mgy (2.6) For simplicity, the beam?s center of mass is adjusted to coincide with the motor shaft. This is not essential as any o set in the beam?s center of mass can be easily compensated for in the controller. Substituting Eqn. 2.5 and Eqn. 2.6 into L = T V yields the Lagrangian L = mr2 2 ( _ _ )2 + md2 2 _ 2 mrd cos ( )( _ _ ) _ + Ib 2 _ 2 mgr cos ( ) +mgd cos ( ) (2.7) Substituting the Lagrangian into the Euler-Lagrange equations, d dt @L @ _ @L @ = Q ; d dt @L @ _ @L @ = Q Here, Q and Q are the generalized forces (torques) corresponding to the two generalized coordinates and , and solving for and produces the following equations for the dynamics of the system (Q = 0 because there is no way to 5 directly apply a generalized force to the ball). = 1 md2 + Ib md2 cos ( ) 2 [mrd sin ( )( _ _ )2 mgd sin ( ) mgd cos ( ) sin ( ) md2 cos ( ) sin ( ) _ 2 +Q ] (2.8) = 1 r(md2 + Ib md2 cos ( ) 2) [mrgd sin ( ) mgd2 sin ( ) cos ( ) +mgd2 sin ( ) mdr2 sin ( )( _ _ )2 +mrd2 cos ( ) sin ( )( _ _ )2 +mrgd cos ( ) sin ( ) +mrd2 cos ( ) sin ( ) _ 2 +md3 sin ( ) Ibg sin ( ) Ibd sin ( ) _ 2 (r d cos ( ))Q ] (2.9) 2.2 Force of Interaction While this model assumes the ball never leaves the beam, in many situations, the ball may easily leave the beam. These cases make the model inappropriate. To ensure the ball stays in contact with beam, the force necessary to keep the ball on the beam was calculated. First, by substituting the time dependent variable for the parameter r, another degree of freedom is added to the system. Then, the additional Euler-Lagrange equation d dt @L @ _ @L @ = Q was derived, with the constraint = r enforced, and the resulting equation solved for the radial force Q required to satisfy the constraint. The equations for and were una ected by this substitution. The results for Q yielded Q = md cos ( ) _ 2 +md sin ( ) mr( _ _ )2 +mg cos ( ) (2.10) 6 Here, Q 0 implies the ball is in contact with the beam, while Q < 0 is physically impossible as this implies the beam is pulling on the ball, hence the ball has left the beam. Thus, when Q < 0, a simulation ignoring this constraint is invalid. 2.3 Dimensionless Parameters To simplify the dynamics of the model, dimensionless parameters were used. The initial model uses seven parameters: m, Ib, d, g, Q , and t. By using the dimensionless time parameter, = pg r t, d dt = pg r d d , d dt = pg r d d , and Q (t) = g r Q^ ( ). From this point on, Q^ , , _ , , , _ and will be in the domain. In addition, the following substitutions will further reduce the number of parameters to four: I^b = Ib md2 , Q = Q^ md2 , R = r d , and ^ = q r g , with as the independent variable. The model is reduced to = 1 I^b + sin ( ) 2 [R sin ( ) _ 2 2R _ sin ( ) _ cos( )sin( ) _ 2 R cos ( ) sin ( ) +R sin ( ) _ 2 R sin ( ) +Q] (2.11) = 1 I^b + sin ( ) 2 [R sin ( ) _ 2 2R _ _ sin ( ) 2 _ 2 cos ( ) sin ( ) +R cos ( ) sin ( ) +R _ 2 sin ( ) R sin ( ) + 2 cos ( ) sin ( ) _ _ cos ( ) sin ( ) _ 2 + sin ( ) cos ( ) sin ( ) + sin ( ) _ 2 R I^b sin ( ) + I^b R sin( ) _ 2 +Q(1 cos ( ) R )] (2.12) Q^ = cos ( ) _ 2 + sin ( ) R( _ _ )2 +R cos ( ) (2.13) 7 where Q^ = Q ^2 md2 . 2.4 Linearized Model To rst test the nonlinear model, a linearized model was created to compare results with the nonlinear model. For a straight beam and ball system, every equi- librium point must satisfy e = 0. However, for a curved beam and ball, e can take many values. For example, by setting Qe = R sin ( e) (the control input), e = e, and _ e = _ e = 0, any value of becomes an equilibrium point as long as the beam is a full circle. However, for simplicity, the model was linearized around e = e = 0. The linear model is then 2 6 6 6 6 6 6 6 6 6 6 4 _ _ 3 7 7 7 7 7 7 7 7 7 7 5 = 2 6 6 6 6 6 6 6 6 6 6 4 0 1 0 0 0 0 R I^b 0 0 0 0 1 1 0 1 + 1 I^b R I^b 0 3 7 7 7 7 7 7 7 7 7 7 5 2 6 6 6 6 6 6 6 6 6 6 4 _ _ 3 7 7 7 7 7 7 7 7 7 7 5 + 2 6 6 6 6 6 6 6 6 6 6 4 0 1 I^b 0 1 I^b (1 1R) 3 7 7 7 7 7 7 7 7 7 7 5 Q (2.14) 2.5 Motor Model A DC motor was incorporated into the model for the simulation (and experi- ment in [1]) using the following equation Q = 1 md2 ( V ^ _ ) (2.15) where and are the motor parameters, V is the input voltage to the motor, and the ^ arises from the conversion to the dimensionless "time" parameter . The motor includes a saturation at an input voltage Vsat. The output torque of this 8 motor model is the torque input of the ball and beam model. The input voltage to the motor is now the new control input into the system. The linear system around zero becomes 2 6 6 6 6 6 6 6 6 6 6 4 _ _ 3 7 7 7 7 7 7 7 7 7 7 5 = 2 6 6 6 6 6 6 6 6 6 6 4 0 1 0 0 0 md2I^b ^ R I^b 0 0 0 0 1 1 md2I^b ^ (1 1R) 1 + 1 I^b R I^b 0 3 7 7 7 7 7 7 7 7 7 7 5 2 6 6 6 6 6 6 6 6 6 6 4 _ _ 3 7 7 7 7 7 7 7 7 7 7 5 + 2 6 6 6 6 6 6 6 6 6 6 4 0 md2I^b 0 md2I^b (1 1R) 3 7 7 7 7 7 7 7 7 7 7 5 V (2.16) with the new input voltage, V , corresponding to the voltage used to drive the motor. From [1], the values determined for the motor used were found as = 0:21 and = 0:11. The dimensions used in the simulation were: r = 0:75m, Ibeam = 0:05kg=m2, mball = 0:02kg, and pivot point d = 0:5m. These values are equivalent to the following dimensionless parameters: R = 1:5, I = 0:050:02(0:5)2=10 , and ^ = q 0:75 9:8 = 0:27. To simplify calculations, full access to the state was assumed. 2.6 Controller The control objective was to stabilize the system at the equilibrium point [ ; _ ; ; _ ] = [0; 0; 0; 0]. The control design strategy used in [1] was the linear quadratic regulator (LQR). This control proved successful in the physical system. Assuming full state feedback, the controller was designed to minimize the perfor- mance measure J = 1 2 Z 1 0 (xT Q^x+ u2)dt (2.17) 9 where the weights are Q^ = 10 I(4 4). These weights ensure that the controller moves fast enough to keep the ball in the linear region. Theoretically, any invertible Q^ should result in a closed-loop nonlinear system that is asymptotically stable by Lyapunov?s rst method. Lyapunov?s method allows any invertible Q^ to be used, and a control gain K can be found for the closed-loop nonlinear system, but the control gains may be unreasonable for a physical system. Using MATLAB?s lqr command, the control gain matrix K was found to control the linear system using feedback. 10 Chapter 3: Parametric Studies 3.1 Overview To compare the e ectiveness of the nonlinear model versus the linear model, we studied how altering the parameters of the system changes the behavior of the closed-loop system. These parameters are R, I^b, md2 , md2 ^ , and Q^ (weight in LQR). In this thesis, we focused on studying R, Q^, and I^b. The main issue is nding the size of the region of attraction in the state space. By changing the value of d speci cally, we can easily alter the values of R and I^b without changing the basic physical setup outlined in [1]. In the implementation, d is adjustable over a fairly large range of values. 3.2 Initial Testing First, to ensure the nonlinear model operated as expected, the initial values found in [1] were considered (r = 0:75m and d = 0:5m, meaning R = 1:5 and I^b = 10). The linear model is stabilized for all initial conditions, while the nonlinear model should only work for a range of initial conditions. Setting the initial conditions for [ ; _ ; ; _ ] = [0:1; 0:1; 0:1; 0:1], both the linear 11 and nonlinear systems are stable, thus driven to [ ; _ ; ; _ ] = [0; 0; 0; 0]. The two systems behave very similarly, despite the initially large di erence in _ values. The results are shown in Figs. 3.1, 3.2, and 3.3. Q is shown in the nonlinear model?s output to show the ball does not leave the beam (Q 0 for the entire simulation). Figure 3.1: Linear model simulation with initial condition [0.1, 0.1, 0.1, 0.1]. Figure 3.2: Nonlinear model simulation with initial condition [0.1, 0.1, 0.1, 0.1]. 12 Figure 3.3: Di erence in nonlinear and linear model simulations with initial condition [0.1, 0.1, 0.1, 0.1]. The graphs show that the nonlinear and linearized systems both act very similarly with the same, "small" (close to 0) initial conditions. However, when the initial states are larger (further away from 0), we expect the nonlinear system to behave di erently, and possibly no longer be stabilizable or for the ball to leave the beam. Note that these are two di erent instabilities. One can, for example, imagine an apparatus where the ball is replaced by a ring that surrounds and slides along the beam. Such a system would eliminate the possibility of ying o the beam, but could still be unstable at any of the possible equilibria. Nonetheless, the primary source of instability in the model is the ball leaving the beam. This can be seen by setting [ ; _ ; ; _ ] = [0; 0; 0; 0:3]. Here, the nonlinear model shows the ball leaving the beam. In the nonlinear model, the states have not increased to a large value where stabilizability is unlikely, yet the ball has left the beam. The results are shown in Figs. 3.4 and 3.5 13 Figure 3.4: Linear model simulation with initial condition [0, 0, 0, 0.3]. Figure 3.5: Nonlinear model simulation with initial condition [0, 0, 0, 0.3]. We are concerned primarily with the initial value of because this is where the ball is initially placed. It is di cult to test nonzero initial conditions of _ and _ because in the physical system, we cannot easily give the ball or beam an initial velocity. We do not consider the initial conditions of and together because then 14 we can position the system so that the ball is at an equilibrium point already (for example, rotate the beam so that the ball is positioned where = 0 would be when = 0). It makes more sense to consider placing the ball at any given position, and keeping the beam at = 0. 3.3 Case d = 0:5m We found that the nonlinear system could operate until 0 = 0:172. The results and comparison of the nonlinear and linear systems can be seen in Figs. 3.6, 3.7, and 3.8. Making the value of 0 any larger would cause the ball to leave the beam (Q < 0) very quickly after starting the simulation. This is shown in Fig. 3.9. Fig. 3.10 shows the state of the model when the ball leaves the beam. Fig. 3.11 shows the control input signal for the nonlinear system at the max 0 value. Figure 3.6: Linear model simulation for d = 0:5m with initial condition [0, 0, 0.172, 0]. 15 Figure 3.7: Nonlinear model simulation for d = 0:5m with initial condi- tion [0, 0, 0.172, 0]. Figure 3.8: Di erence in nonlinear and linear model simulations for d = 0:5m with initial condition [0, 0, 0.172, 0]. 16 Figure 3.9: Nonlinear model for d = 0:5m with initial condition [0, 0, 0.173, 0]. (a) Ball and beam initial states (b) States of system when ball leaves Figure 3.10: States of the system for nonlinear model initially ( = 0 and = 0:172) and when the ball leaves the beam ( = 0:226 and = 0:257) for d = 0:5m. 17 Figure 3.11: Input signal for nonlinear model simulation for d = 0:5m with initial condition [0, 0, 0.172, 0]. 3.4 Case d = 0:375m Next, we considered when the pivot is halfway between the beam and the center of the circle formed by the beam. In this case, r = 0:75m and d = 0:375m, thus R = 2 and I^b = 17:77. Again, the results didn?t di er too much in terms of what initial conditions make it impossible to stabilize the nonlinear system. The system acts very similarly to what occurs when R = 1:5, which is expected. Surprisingly, the maximum initial value of that allows the nonlinear system to be stabilizable is much lower than the R = 1:5 case (maximum 0 = 0:15). However, we know that when d = 0 (so the pivot is at the center of the circle), the system is not stabilizable at all because R = 1. Thus, we now expect the possible domain of attraction of the origin to decrease as d becomes smaller, as is evident from these results. Figs. 3.12, 3.13, and 3.14. refer to the case d = 0:375m. Again, choosing a 18 0 larger than 0:150 causes the ball to leave the beam, as shown in Fig. 3.15, and Fig. 3.16 shows the state of the model when the ball leaves the beam. Fig. 3.17 shows the control input signal for the nonlinear system at the max 0 value. Figure 3.12: Linear model simulation for d = 0:375m with initial condi- tion [0, 0, 0.150, 0]. Figure 3.13: Nonlinear model simulation for d = 0:375m with initial condition [0, 0, 0.150, 0]. 19 Figure 3.14: Di erence in nonlinear and linear model simulations for d = 0:375m with initial condition [0, 0, 0.150, 0]. Figure 3.15: Nonlinear model for d = 0:375m with initial condition [0, 0, 0.151, 0]. 20 (a) Ball and beam initial states (b) States of system when ball leaves Figure 3.16: States of the system for nonlinear model initially ( = 0 and = 0:150) and when the ball leaves the beam ( = 0:349 and = 0:339) for d = 0:375m. Figure 3.17: Input signal for nonlinear model simulation for d = 0:375m with initial condition [0, 0, 0.150, 0]. 21 3.5 Case d = 0:75m Now we consider when the pivot is located on the beam itself. In this case, r = 0:75m and d = 0:75m, thus R = 1 and I^b = 4:44. We found that the results didn?t di er too much in terms of what initial conditions make the nonlinear linear system no longer stabilizable (the max 0 = 0:171). However, we can clearly see that the system acts di erently with the new pivot position. The results and comparison of the nonlinear and linear systems can be seen in Figs. 3.18, 3.19, and 3.20. Again, making 0 any larger than 0:171 caused the ball to leave the beam, as shown in Fig. 3.21. Fig. 3.22 shows the state of the model when the ball leaves the beam. Fig. 3.23 shows the control input signal for the nonlinear system at the max 0 value. Figure 3.18: Linear model simulation for d = 0:75m with initial condition [0, 0, 0.171, 0]. 22 Figure 3.19: Nonlinear model simulation for d = 0:75m with initial condition [0, 0, 0.171, 0]. Figure 3.20: Di erence in nonlinear and linear model simulations for d = 0:75m with initial condition [0, 0, 0.171, 0]. 23 Figure 3.21: Nonlinear model for d = 0:75m with initial condition [0, 0, 0.172, 0]. (a) Ball and beam initial states (b) States of system when ball leaves Figure 3.22: States of the system for nonlinear model initially ( = 0 and = 0:171) and when the ball leaves the beam ( = 0:045 and = 0:172) for d = 0:75m. 24 Figure 3.23: Input signal for nonlinear model simulation for d = 0:75m with initial condition [0, 0, 0.171, 0]. 3.6 Case d = 1:5m The next two cases consider a situation when the pivot was outside the beam (so the motor shaft is connected above the beam). The rst case considered was r = 0:75m and d = 1:5m so R = 0:5 and I^b = 1:11. In this case, the pivot is twice the radius away from the center of the circle. We nd that the system performs better than if the pivot is inside the beam in terms of the size of domain of attraction. For this case, the maximum 0 = 0:187, which is an improvement of 0:16. However, the time it takes for the system to reach [ ; _ ; ; _ ] = [0; 0; 0; 0] has increased, but not by a signi cant amount. Figs. 3.24, 3.25, and 3.26 show the outputs and di erences between the nonlinear and linear models. Again, increasing 0 over 0:187 causes the ball to leave the beam, as shown in Fig. 3.27. Fig. 3.28 shows the state of the model when the ball leaves the beam. Fig. 3.29 shows the control input signal for 25 the nonlinear system at the max 0 value. Figure 3.24: Linear model simulation for d = 1:5m with initial condition [0, 0, 0.187, 0]. Figure 3.25: Nonlinear model simulation for d = 1:5m with initial con- dition [0, 0, 0.187, 0]. 26 Figure 3.26: Di erence in nonlinear and linear model simulations for d = 1:5m with initial condition [0, 0, 0.187, 0]. Figure 3.27: Nonlinear model for d = 1:5m with initial condition [0, 0, 0.188, 0]. 27 (a) Ball and beam initial states (b) States of system when ball leaves Figure 3.28: States of the system for nonlinear model initially ( = 0 and = 0:187) and when the ball leaves the beam ( = 0:014 and = 0:175) for d = 1:5m. Figure 3.29: Input signal for nonlinear model simulation for d = 1:5m with initial condition [0, 0, 0.187, 0]. 28 3.7 Case d = 7:5m The second case for placing the pivot outside the beam considered placing the pivot very far from the beam. To observe this setup, we considered making r = 0:75m and d = 7:5m so R = 0:1 and I^b = 0:04. In this setup, the model can be stabilized for fairly large values of 0. The maximum 0 = 0:463, which is a signi cant increase compared to every other case. However, there is a noticeable increase in time to converge. The time to reach equilibrium is over three times the amount needed for the cases when the pivot is inside the beam. The results are shown in Figs. 3.30, 3.31, and 3.32. Fig. 3.33 shows the ball leaving the beam when 0 was chosen greater than 0:463, and Fig. 3.34 shows the state of the model when the ball leaves the beam. Fig. 3.35 shows the control input signal for the nonlinear system at the max 0 value. Figure 3.30: Linear model simulation for d = 7:5m with initial condition [0, 0, 0.463, 0]. 29 Figure 3.31: Nonlinear model simulation for d = 7:5m with initial con- dition [0, 0, 0.463, 0]. Figure 3.32: Di erence in nonlinear and linear model simulations for d = 7:5m with initial condition [0, 0, 0.463, 0]. 30 Figure 3.33: Nonlinear model for d = 7:5m with initial condition [0, 0, 0.464, 0]. 31 (a) Ball and beam initial states (b) States of system when ball leaves Figure 3.34: States of the system for nonlinear model initially ( = 0 and = 0:463) and when the ball leaves the beam ( = 0:004 and = 0:436) for d = 7:5m. 32 Figure 3.35: Input signal for nonlinear model simulation for d = 7:5m with initial condition [0, 0, 0.463, 0]. An interesting result discovered from these tests is that we can see a pattern concerning the boundary of stabilizability, max, and the value of d. Obviously, when d = 0, the models are unstabilizable, because R = rd = 1. As d grows, the boundary increases until d gets close to r. When that happens, the max levels out around 0:17, and slightly decreases as it reaches r, before increasing again when d > r. This can be seen in Fig. 3.36 33 Figure 3.36: Plot of maximum 0 value vs d. 3.8 Causes for Ball Leaving the Beam To understand more clearly what is causing the ball to leave the beam, we checked the di erent components of Q to determine which terms are the primary causes for the ball to leave the beam. First, we removed the cos ( ) _ 2 term in the calculation of Q^ . By removing this term, we know if _ or _ is causing the ball to leave the beam (since and are inside sinusoids, these do not play a direct part in determining whether the ball leaves the beam). If the ball now leaves the beam with smaller initial values, then we know that _ is helping keep the ball on the beam. After running the simulations again, we found that the model performed worse. For every value of d, the ball left the beam with smaller initial values of in both 34 the nonlinear and linear systems. For the case d = 0:5m (R = 1:5), the boundary for stabilizability is 0 = 0:130 instead of 0:172. When d = 0:37m5 (R = 2), the boundary is 0 = 0:128 instead of 0:15. When d = 0:75m (R = 1), the boundary is 0 = 0:138 instead of 0:171. When d = 1:5m (R = 0:5), the boundary is 0 = 0:170 instead of 0:187. When d = 7:5m (R = 0:1), the boundary is 0 = 0:442 instead of 0:463. Next, we removed the md sin ( ) term in Q . Since this term contains , it is an important component in the calculation of Q . This term is directly a ected by d. When the pivot is located inside the beam, the boundary of stabilizability has improved (we later nd these results are the same as ignoring Q ). We nd that when d = 0:5 (R = 1:5), the boundary for stabilizability is 0 = 0:215 instead of 0:172. When d = 0:375 (R = 2), the boundary is 0 = 0:17 instead of 0:15. When d = 0:75 (R = 1), the boundary is 0 = 0:294 instead of 0:171. When the pivot is located outside the beam, the nonlinear model performs better as well (but not as well as ignoring Q ). When d = 1:5m (R = 0:5), the boundary is 0 = 0:386 instead of 0:187. When d = 7:5m (R = 0:1), the boundary is 0 = 0:606 instead of 0:463. Next, we removed the mr( _ _ )2 term. Since this term is always negative, removing this term should always improve the performance of the system. This is con rmed after testing. For the case d = 0:5m (R = 1:5), the boundary for stabilizability is 0 = 0:184 instead of 0:172. When d = 0:375m (R = 2), the boundary is 0 = 0:154 instead of 0:15. When d = 0:75m (R = 1), the boundary is 0 = 0:238 instead of 0:171. When d = 1:5m (R = 0:5), the boundary is 0 = 0:243 instead of 0:187. When d = 7:5m (R = 0:1), the boundary is 0 = 0:500 instead of 35 0:463. Finally, we removed the mg cos ( ) term. Without this term, the nonlinear model simulation immediately has a negative Q value for every value of d (except at [0; 0; 0; 0]). Thus, this term is the major one holding the ball on the beam. This is unsurprising because it is the term due to gravity, which is necessary for the ball to stay on the beam. As another test of the system, the constraint that the ball remain on the beam was removed. This is a plausible test if we made the circular beam into a tube so that the ball never leaves the system. The model dynamics are not a ected, but Q is no longer needed. Testing for the same initial conditions, we nd that when d = 0:5 (R = 1:5), the boundary for stabilizability is 0 = 0:215 instead of 0:172. When d = 0:375 (R = 2), the boundary is 0 = 0:17 instead of 0:15. When d = 0:75 (R = 1), the boundary is 0 = 0:294 instead of 0:171. When d = 1:5 (R = 0:5), the boundary is 0 = 0:546 instead of 0:187. When d = 7:5 (R = 0:1), the boundary is 0 = 1:224 instead of 0:463. Thus, the system is stabilizable for much larger initial conditions by removing the constraint that the ball remain on the beam. The results for testing Q are plotted in Fig. 3.37 36 Figure 3.37: Plot of Max 0 vs d after altering Q . 37 Chapter 4: Nonlinear Controls 4.1 Feedback Linearization To truly test the nonlinear model, nonlinear control techniques were consid- ered for controlling the nonlinear model. A common approach to solving nonlinear systems is feedback linearization. The goal of feedback linearization is to determine a transformation of the nonlinear system into a linear system with suitable control input. The general class of nonlinear systems take the form _x = f(x) + g(x)u y = h(x) So, with a state feedback control u = (x) + (x)v ( and not related to motor values), and a change of variables z = T (x), the nonlinear system can be transformed into an equivalent linear system if the system is feedback linearizable. According to Chapter 13.3, of [2], the nonlinear system with domain D is feedback linearizable if and only if there is domain D0 D such that 1. The matrix G(x) = [g(x); adfg(x); :::; ad n 1 f g(x)] has full rank 8x 2 D0 2. The distribution D = spanfg(x); adfg(x); :::; ad n 2 f g(x)g is involutive in D0. 38 where ad0fg(x) = g(x) adfg(x) = [f(x); g(x)] adkfg(x) = [f(x); ad k 1 f g(x)] Here, [f(x); g(x)] = @g@xf(x) @f @xg(x) refers to the Lie Bracket. A nonsingular distribution 4 = spanff1(x); f2(x); :::; fn(x)g (so the span is Rn) is involutive if and only if [fi(x); fj(x)] 2 4; 8 1 i; j k To test involutivity, we calculated rst tested the rank of G(x) in varying regions, and found it was nonsingular in large regions around zero. To test these regions for involutivity, we found D, and then computed the Lie brackets of every vector. To con rm that each Lie bracket was still an element of the span, we computed the determinant of the matrix containing all the Lie brackets, and tested to ensure it had determinant equal 0. Testing our model, we found the system is not involutive in any signi cant region. This is consistent with our inability to determine a change of variables to transform the nonlinear system into a linear system. A transform could not be found to successfully create a linear system. 39 4.2 Lyapunov Studies From the LQR calculations, we obtain the unique S matrix that solves the Riccati equation ATS + SA SBR 1BTS + Q^ = 0 (4.1) with K = R 1BTS Using this S matrix, we can create a candidate Lyapunov function V (x) = 1 2 xTSx _V (x) = 1 2 (xTS _x+ _xTSx) (4.2) Here, _x = [A BK]x + fl(x), with fl(x) = gcl(x) (A BK)x, and gcl(x) is the closed loop vector eld of the system (so fl(x) is the "leftover" terms after removing the linearized equation from the nonlinear model). Thus _V (x) = 1 2 xT (S(A BK) + (A BK)TS)x+ 1 2 xTSfl(x) + 1 2 fl(x) TSx (4.3) We know Eq. 4.1 so _V (x) = 12x T ( Q SBTR 1BTS)x+ 12x TSfl(x) + 12fl(x) TSx V (x) > 0 and _V (x) 0 for small enough fl(x) and kfl(x)k ! 0 as x ! 0 at least as fast as kxk2, so it is a viable Lyapunov function. We would like to solve where _V (x) = 0 because this is the boundary of the region we can prove is the domain of attraction of [0; 0; 0; 0]. Considering the case where d = 0:5, we computed _V (x) for various regions of x, and found several states where _V (x) = 0. Ignoring the case of [0; 0; 0; 0], we nd that these solutions require at least one state being greater than 40 0.2. However, it was observed that the system is unstabilizable or the ball ies o the beam when 0 > 0:2. Testing for the other states beginning at 0.2 reveals the system is unstabilizable or the ball ies o the beam. Thus, the smallest boundary of the domain of attraction is the "circle" of radius 0.2 for every state. Testing for the other cases of d reveal similar results. To study the Lyapunov stabiliyu further, we considered varying the value of Q^ in 2.17. The rst two cases considered increasing or decreasing the coe cient in front of the identity matrix. First, we considered decreasing Q^ from 10 I4x4 to 5 I4x4. This resulted in slightly better results in terms of maximum 0 when the pivot was located on or outside the beam, but performed the same if the pivot was located inside the beam. When we increased Q^ to 50 I4x4, the model performed worse except at d = 0:375, where max 0 remained the same. Next, we focused on the ball states, and _ . We gave these states more weight so that the ball movement is minimized. First, we tested [1; 1; 10; 10] I4x4. We found that the nonlinear model performed better, and performance improved more as we moved the pivot further from the center of the beam circle. Next, we tested [1; 1; 1; 10] I4x4. Again, the performance improved, though when the pivot is outside the beam, it does not improve as well as [1; 1; 10; 10] I4x4. Finally, we tested a case where the beam state is weighed less, and the velocities are given the most weight. The performance improved when the pivot is outside the beam. However, when the pivot is inside the beam, the performance is worse. Fig. 4.1 shows the results for various values of the Q^. 41 Figure 4.1: The max initial phi value vs pivot distance when altering the Q in LQR. 42 Chapter 5: New Coordinate System 5.1 Model Figure 5.1: A new coordinate system for testing. It is helpful to study the ball and circular beam using a slightly di erent coor- dinate system. De ne and as shown in Fig. 5.1. Notice that, in this coordinate system, = 0 at every equilibrium point and that any value of can be an equilib- rium value with an appropriate control signal, since = . This is fundamentally di erent from the ball and straight beam where there is only one equilibrium value for the beam, while the ball can have its equilibrium value anywhere on the beam. In fact, the circular beam and ball most resembles the inverted pendulum on a cart 43 when it is near an equilibrium point. The x, y positions and velocities from Eqs. 2.1, 2.2, 2.3, and 2.4 become x =r sin ( ) + d sin ( ) y =r cos ( ) d sin ( ) _x =r cos ( ) _ + d cos ( ) _ _y = r sin ( ) _ d sin ( ) _ (5.1) Following the same derivation for total energy and the Lagrangian equations, the equations describing the dynamics of the ball and circular beam in these new coor- dinates are Q = (Ib +md 2) +mrd cos ( + ) mrd sin ( + ) _ 2 + mdg sin ( ) (5.2) 0 = mrd cos ( + ) +mr2 mrd sin ( + theta) _ 2 mgr sin ( ) (5.3) 0 md +md _ 2 cos ( + ) mr _ 2 +mg cos ( ) (5.4) In the following analysis, we will assume that the motor dynamics and possible saturation can be ignored. This is reasonable, provided one has a very large and powerful motor. It allows us to focus on the fundamental aspects of the dynamics. Using Q as the control, it is then possible to approximately linearize Eq. 5.2 by letting Q = 1 Ib +md2 ( mrd sin ( + ) _ 2 +mgd sin ( ) + u^) (5.5) u^ = + mrd cos ( + ) Ib +md2 (5.6) The accuracy of this approximation can be improved by choosing the inertia of the beam to be large compared to the mass of the ball, as is the case for the inverted 44 pendulum problem, where the control is simpli ed by choosing a powerful motor and a heavy cart. One can then view the ball (or the pendulum) as a (small) perturbation of the beam dynamics. Under these assumptions, the beam dynamics become a simple double integrator, as shown is Eqn. 5.7. u^ (5.7) Next, one substitutes these simpli ed and linear dynamics into Eqn. 5.3. The ball dynamics can then by linearized by choosing the control to be u^ = 1 mrd cos ( + ) (mrd sin ( + ) _ 2 +mgr sin ( ) + u) (5.8) In fact, this equation is valid for the full dynamics, including the neglected small e ect of the ball on the beam dynamics. The di erence between the exact and approximate descriptions is in the complexity of the control. This is signi cant because this new control also drives the beam, making the beam dynamics nonlinear and complicated. The resulting dynamics become = u mr = tan ( + ) _ 2 + g d sin ( ) cos ( + ) + u (5.9) Notice that the ball dynamics are linear and decoupled from those of the beam, but the beam dynamics are both nonlinear and unstable. However, one can now choose a linear feedback state control that will stabilize the whole system and keep the ball dynamics linear in the state variables. However, this control does put the nonlinear dynamics of the beam back into the ball motion. The linearized approximated model 45 can then be expressed as shown in Eqn. 5.10. 2 6 6 6 6 6 6 6 6 6 6 4 _ _ 3 7 7 7 7 7 7 7 7 7 7 5 = 2 6 6 6 6 6 6 6 6 6 6 4 0 0 1 0 0 0 0 1 0 0 0 0 g d 0 0 0 3 7 7 7 7 7 7 7 7 7 7 5 2 6 6 6 6 6 6 6 6 6 6 4 _ _ 3 7 7 7 7 7 7 7 7 7 7 5 + 2 6 6 6 6 6 6 6 6 6 6 4 0 0 1 mr 1 3 7 7 7 7 7 7 7 7 7 7 5 u (5.10) Then, the nonlinear approximate model can be written as shown in Eqn. 5.11. 2 6 6 6 6 6 6 6 6 6 6 4 _ _ 3 7 7 7 7 7 7 7 7 7 7 5 = 2 6 6 6 6 6 6 6 6 6 6 4 0 0 1 0 0 0 0 1 0 0 0 0 g d 0 0 0 3 7 7 7 7 7 7 7 7 7 7 5 2 6 6 6 6 6 6 6 6 6 6 4 _ _ 3 7 7 7 7 7 7 7 7 7 7 5 + 2 6 6 6 6 6 6 6 6 6 6 4 0 0 1 mr 1 3 7 7 7 7 7 7 7 7 7 7 5 u+ 2 6 6 6 6 6 6 6 6 6 6 4 0 0 0 tan ( + ) _ 2 + gd( sin ( ) cos ( + ) ) 3 7 7 7 7 7 7 7 7 7 7 5 (5.11) Simulating this model using the LQR for the control input, we see that this model performs much better. Using d = 0:5, so R = 1:5 and I = 10, we nd the nonlinear model is stabilizable and still maintains contact with the beam for 0 = 0:626, which is much better than the previous coordinate system (since = 0, both and are the same value). For d = :75, the nonlinear model is stabilizable up to 0 = 0:774. For d = :375, the nonlinear model is stabilizable up to 0 = 0:539. For d = 1:5, the nonlinear model is stabilizable up to 0 = 0:434. For d = 7:5, the nonlinear model is stabilizable up to 0 = 0:125. This is di erent than the previous coordinate system, because this system performs worse if the pivot is located outside the arc, whereas the previous system performs better moving the pivot outside the arc. Figs. 5.2, 5.3, and 5.4 are plots of the case d = 0:5. Increasing 0 to 0:627 when d = 0:5 causes the ball to leave the beam, as shown in Fig. 5.5. 46 Figure 5.2: Linear model simulation in new coordinate system with ini- tial condition [0.626, 0, 0, 0]. Figure 5.3: Nonlinear model simulation in new coordinate system with initial condition [0.626, 0, 0, 0]. 47 Figure 5.4: Di erence in nonlinear and linear model simulations in new coordinate system with initial condition [0.626, 0, 0, 0]. Figure 5.5: Nonlinear model in new coordinate system with initial con- dition [0.627, 0, 0, 0]. Solving for the optimal cost from the LQR, we followed the same procedure as Eqn. 4.2, and solved for when _V (x) = 0. Again, there were multiple states where _V (x) = 0, however, they were not always close to the origin. In this coordinate 48 system, the system is also stabilizable for larger initial states. For the case d = 0:5, so R = 1:5 and I = 10, at least one state is greater than 0.2, but the system is still stabilizable. Thus, this system is locally stabilizable for a much larger region, which is evident with the fact the system maintains contact with the beam and remains stabilizable for much larger regions for this case. We found the system maintains _V (x) < 0 for a region with kxk 0:2. In this region, the system is still stabilizable and the ball maintains contact with the beam. 49 Chapter 6: Conclusion In this thesis, corrections were made to Sheng?s model [1] and some nonlinear techniques were tested. We compared the performance of the linear model with the nonlinear model using an LQR control input. We also tested for feedback lin- earization, and tested Lyapunov stability of the nonlinear model. Finally, a new coordinate system was tested, using both an approximated nonlinear and linearized models. Using this new coordinate system, the results of the two systems were compared. 50 Bibliography [1] Sheng, J., Renner, J., and Levine, W., A Ball and Curved O set Beam Exper- iment (2010 American Control Conference, 2010). [2] Khahil, H., Nonlinear Systems. (Prentice Hall, Upper Saddle River, New Jersey, 3rd Edition, 2002). [3] Hauser, J. Sastry, S, and Kokotovic, P., Nonlinear Control Via Approximate Input-Output Linearization: The Ball and Beam Example (IEEE, 1992). 51