EECS 6B Designing Information Devices and Systems II Spring 28 J. Roychowdhury and M. Maharbiz Homework 7 This homework is due on Thursday, March 22, 28, at :59AM (NOON). Self-grades are due on Monday, March 26, 28, at :59AM (NOON). Pre-Lab. Closed-Loop Control of SIXT33N Last time, we discovered that open-loop control was not enough to ensure that our car goes straight in the event of model mismatch. In this problem, we will introduce closed-loop control which will hopefully make SIXT33N finally go straight. Previously, we introduced δt = d L t d R t as the difference in positions between the two wheels. If both wheels of the car are going at the same velocity, then this difference δ should remain constant, since no wheel will advance by more ticks than the other. In our closed loop control scheme, we will consider a control scheme which will apply a simple proportional control k L and k R against δt in order to try to prevent δt from growing without bound. We want to achieve the following equations: v L t = d L t + d L t = u L t β L v R t = d R t + d R t = u R t β R v L t = d L t + d L t = v k L δt v R t = d R t + d R t = v + k R δt We can put the equations in the following form to figure out how we should change our control inputs. v L t = d L t + d L t = ( v + β L v R t = d R t + d R t = ( v + β R ) δt k L + k R δt β L ) β R These are our new closed-loop control inputs the new closed-loop proportional control is the k L /k R term. u L t = v + β L u R t = v + β R δt k L δt + k R EECS 6B, Spring 28, Homework 7
(a) Let s examine the feedback proportions k L and k R more closely. Should they be positive or negative? What do they mean? Think about how they interact with δt. If δt >, it means that d L t > d R t, so the left wheel is ahead of the right one. In order to correct for this, we should help the right wheel catch up, and we should do this by making k L > in order to apply less power on the left wheel and k R > in order to apply more power to the right wheel. Likewise, if δt <, it means that d L t < d R t, so the right wheel is ahead of the left one. In this case, k L > is still valid, since k L δt > and so the left wheel speeds up, and likewise k R > is still correct since k R δt < so the right wheel slows down. (b) Let s look a bit more closely at picking k L and k R. First, we need to figure out what happens to δt over time. Find δt + in terms of δt. δt + = d L t + d R t + = v k L δt + d L t (v + k R δt + d R t) = v k L δt + d L t v k R δt d R t = k L δt k R δt + (d L t d R t) = k L δt k R δt + δt = δt( k L k R ) (c) Given your work above, what is the eigenvalue of the system defined by δt? For discrete-time systems like our system, λ (,) is considered stable. Are λ,) and λ (, identical in function for our system? Which one is better? (Hint: Preventing oscillation is a desired benefit.) Based on your choice for the range of λ above, how should we set k L and k R in the end? The eigenvalue is λ = k L k R. As a discrete system, both are stable, but λ (, will cause the car to oscillate due to overly high gain. Therefore, we should choose λ,). As a result, k L k R,) = (k L + k R ) (, means that we should set the gains such that (k L + k R ),). (d) Let s re-introduce the model mismatch from last week in order to model environmental discrepancies, disturbances, etc. How does closed-loop control fare under model mismatch? Find δ ss = δt, assuming that δ = δ. What is δ ss? (To make this easier, you may leave your answer in terms of appropriately defined c and λ obtained from an equation in the form of δt + = δtλ + c.) Check your work by verifying that you reproduce the equation in part (c) if all model mismatch terms are zero. Is it better than the open-loop model mismatch case from last week? v L t = d L t + d L t = ( + )u L t (β L + β L ) v R t = d R t + d R t = ( + )u R t (β R + β R ) EECS 6B, Spring 28, Homework 7 2
u L t = v + β L δt k L u R t = v + β R + k R δt δt + = d L t + d R t + = ( + )u L t (β L + β L ) + d L t (( + )u R t (β R + β R ) + d R t) = u L t β L + u L t β L + d L t ( u R t β R + u R t β R + d R t) = v k L δt + u L t β L + d L t (v + k R δt + u R t β R + d R t) = v k L δt + u L t β L + d L t v k R δt u R t + β R d R t = v v + (d L t d R t) k L δt k R δt + u L t β L u R t + β R = δt( k L k R ) + u L t β L u R t + β R = δt( k L k R ) + ( v + β L k L δt ) ( v + β R δt + k R ) β L + β R = δt( k L k R ) + (v + β L ) δtk L (v + β R ) δtk R β L + β R θ ( ) R = δt k L k R k L k R + (v + β L ) (v + β R ) β L + β R ( ) ( ) ( ) θl = δt k L k R k L k R + (v θr + β L ) β L (v + β R ) β R Let us define c = k L k R k L ( ) ( ) θl (v θr + β L ) β L (v + β R ) β R, and our new eigenvalue λ = k R. In this case, δ = δ λ + c δ2 = λ(δ λ + c) + c δ3 = λ(δ λ 2 + cλ + c) + c δ4 = λ(δ λ 3 + cλ 2 + cλ + c) + c δ5 = δ λ 5 + c(λ 4 + λ 3 + λ 2 + λ + ) δn = δ λ n + c( + λ + λ 2 + λ 3 + λ 4 +... + λ n ) ( n k=λ k ) δn = δ λ n + c (rewriting in sum notation) ( ) λ δn = δ λ n n + c (sum of a geometric series) λ = δ λ 2 + cλ + c = δ λ 3 + cλ 2 + cλ + c = δ λ 4 + cλ 3 + cλ 2 + cλ + c If λ <, then λ =, so those terms drop out: EECS 6B, Spring 28, Homework 7 3
( ) λ δn = t = δ λ + c λ δn = t = c λ δ ss = c λ For your entertainment only: δ ss is fully-expanded form (not required) is ( ) ( ) θl (v θr + β L ) β L (v + β R ) β R k L + k R + k L + k R The answer is correct because plugging in zero into all the model mismatch terms into c causes c =, so δ ss = if there is no model mismatch. Compared to the open-loop result of δ ss = ±, the closed loop δ ss = c is a much-desired improvement. λ What does this mean for the car? It means that the car will turn initially for a bit but eventually converge to a fixed heading and keep going straight from there. Problems 2. Design for Controllability and Observability I We are given a system with tunable parameter γ. x(t) = 3 3 x(t) + u(t) γ 4 x(t) + u(t) y(t) = (a) How should we tune γ to make the system controllable but not observable? The controllability matrix is and the observability matrix is C = B 3 AB = γ C O = =. CA γ 3 Thus, to make the system controllable but not observable, we should choose γ = 2. (b) How should we tune γ to make the system observable but not controllable? To make the system observable but not controllable, we should choose γ =. EECS 6B, Spring 28, Homework 7 4
3. Design for Controllability and Observability II We are given a new system x(t) = x(t). 2 along with only one sensor and one actuator to control and observe the system. (a) Which state should we control with the actuator to make the system controllable? We should control the state x. This makes the control matrix B =, so C =. (b) Which state should we measure with the sensor to make the system observable? We should measure the state x 2. This makes the measurement matrix C =, so O =. 2 4. Observability Consider the following continuous time system. x(t) = A x(t) + B u(t) y(t) = C x(t) We want to construct an estimate z of the system state x. To do so, we construct a pretend system with the same A,B,C models, the same input and the output of the last system along with an L system matrix. We do this to try and exploit the difference between the output of our pretend state and the actual output, with L being the knob that we can control. z(t) = A z(t) + B u(t) + L(C z(t) y(t)) (2) Define e(t) = z(t) x(t). This is the error term as a function of time. (a) Using the two systems defined above, construct a system of the form, Subtracting () from (2), we get the desired answer: d e (t) = (A + LC) e(t) (3) dt z(t) x(t) = A z(t) + B u(t) + L(C z(t) y(t)) A x(t) B u(t) e(t) = A( z(t) x(t)) + L(C z(t) C x(t)) e(t) = A e(t) + LC( z(t) x(t)) e(t) = (A + LC) e(t) () EECS 6B, Spring 28, Homework 7 5
(b) We want What does that imply about (3)? lim e(t) = t This means that we want (3) to be stable: all of the eigenvalues of A+LC should have a real component less than zero. (c) Does the initial value of the guess z() matter in the long term? Not really, since the e(t) tends to. This means that no matter how bad our initial guess, we will eventually have a good estimate. 5. Rank Decomposition In this problem, we will decompose a few images into linear combinations of rank matrices. (a) Consider a standard 8 8 chessboard shown in Figure. Assume that black colors represent and that white colors represent. Figure : 8 8 chessboard. Decompose this image into rank images. Draw out each of these rank images and express the original chessboard as a linear combination of the individual rank images. The chessboard is already a rank image, so we do not need to decompose it further. (b) Assume that the chessboard is given by the following 8 8 matrix C : C = Express C as a linear combination of outer products. EECS 6B, Spring 28, Homework 7 6
Using the result from the previous part, C = (c) For the same chessboard shown in Figure, now assume that black colors represent and that white colors represent. Decompose this image into rank images. Draw out each of these rank images and express the original chessboard as a linear combination of the individual rank images. The chessboard is now a rank 2 image, so we need to decompose it. Image : Image 2: The chessboard equals the sum of image and image 2. EECS 6B, Spring 28, Homework 7 7
(d) Assume that the chessboard is given by the following 8 8 matrix C 2 : C 2 = Express C as a linear combination of outer products. Using the result from the previous part, C 2 = + (e) Now consider the Swiss flag shown in Figure 2. Assume that red colors represent and that white colors represent. Figure 2: Swiss flag. Decompose this image into rank images. Draw out each of these rank images and express the Swiss flag as a linear combination of the individual rank images. The Swiss flag is a rank 2 image, so we need to find two rank images. Solution : Image : EECS 6B, Spring 28, Homework 7 8
Image 2: The Swiss flag equals the sum of image and image 2. Solution 2: Image : Image 2: The Swiss flag equals the difference between image and image 2. EECS 6B, Spring 28, Homework 7 9
(f) Assume that the Swiss flag is given by the following 5 5 matrix S: S = Express S as a linear combination of outer products. We can use the result from the previous part. Solution : S = + Solution 2: S = 6. Balance Justin is working on a small jumping robot named Salto. Salto can bounce around on the ground, but Justin would like Salto to balance on its toe and stand still. In this problem, we ll work on systems that could help Salto balance on its toe using its reaction wheel tail. EECS 6B, Spring 28, Homework 7
Figure 3: Picture of Salto and the x-z physics model. You can watch a video of Salto here: http://www. youtube.com/watch?v=2djmarhrnu Standing on the ground, Salto s dynamics in the x-z plane (called the sagittal plane in biology) look like an inverted pendulum with a flywheel on the end: (I + (m + m 2 )l 2 ) θ = K t u + (m + m 2 )lgsin(θ ) I 2 θ 2 = K t u where θ is the angle of the robot s body relative to the ground ( is straight up), θ is its angular velocity, θ 2 is the angular velocity of the reaction wheel tail, and u is the current input to the tail motor. m,m 2,I,I 2,l,K t are positive constants representing system parameters (masses and angular momentums of the body and tail, leg length, and motor torque constant respectively) and g = 9.8 m s 2 is the acceleration due to gravity. Numerically substituting Salto s physical parameters, the differential equations become approximately:. θ =.25u +.sin(θ ) 5( 5 ) θ 2 =.25u For this problem, we ll look at a reduced suite of sensors on Salto. Our only output will be the tail encoder that measures the angular velocity of the tail relative to the body: y = θ 2 θ (a) Using the state vector. Write the linearized equations as d dt θ θ θ 2, input u, and output y linearize the system about the point x = A x + Bu and y = C x. Write out the matrices with the physical numerical values, not symbolically. Note: Since the tail is like a wheel, we care only about its angular velocity θ 2 and not its angle θ 2. EECS 6B, Spring 28, Homework 7
Numerically, the dynamics are: θ θ θ = θ + 25 u θ 2 θ 2 5 θ y = θ θ 2 For those interested, the symbolic dynamics are: θ (m θ = +m 2 )lgsin(θ) θ I +(m +m 2 )l θ 2 θ + 2 θ 2 θ y = θ θ 2 K t I +(m +m 2 )l 2 K t I 2 u (b) Is the system fully controllable? Is the system fully observable? C = B AB A 2 B 25 = 25 25 5 which is full rank, so the system is fully controllable. C O = CA = CA 2 which is rank 3, so the system is fully observable. (c) Design an observer of the form d dt ˆx = A ˆx + Bu + L(C ˆx y) and solve for the gains in L that make the observer dynamics converge with all eigenvalues λ = λ 2 = λ 3 =. The observer dynamics are dictated by e = (A + LC) e where e is the error between the estimated state ˆx and the true state x. The characteristic polynomial is: det(a + LC) = l l det l 2 l 2 = l 3 l 3 λ 3 + ( l 3 + l 2 )λ 2 + (l )λ + l 3 = EECS 6B, Spring 28, Homework 7 2
The desired characteristic polynomial is: (λ + ) 3 = λ 3 + 3λ 2 + 3λ + = which we can achieve by matching the coefficients of matching powers: l 3 + l 2 = 3 l = 3 l 3 = These equations are solved by the gains: l = 4, l 2 = 4, and l 3 =. Written as a matrix, 4 L = 4 (d) Let s implement a controller for our system using an analog electrical circuit! You can use the following circuit components in Figure 2: Figure 4: Circuit components and block diagram symbols. EECS 6B, Spring 28, Homework 7 3
Using state feedback, Justin has selected the control gains K = 2 5. for his input u = K x. Draw a block diagram in the box in Figure 5 that implements this controller. Afterwards, design the circuit that implements the controller. Use relatively reasonable component values. Optional: What are the eigenvalues of the closed loop dynamics for the given K? Figure 5: Fill in the box to implement the state feedback controller. Figure 6: Here is a possible circuit. Other resistor values will work as long as the gains are the same. Optional: The eigenvalues are λ = 6.6 and λ =.697 ±.87 j. EECS 6B, Spring 28, Homework 7 4
Contributors: Edward Wang. John Maidens. Siddharth Iyer. Titan Yuan. Justin Yim. EECS 6B, Spring 28, Homework 7 5