Dr. J. Tani, Prof. Dr. E. Frazzoli 151-0591-00 Control Systems I (HS 2018) Exercise Set 2 Topic: Modeling, Linearization Discussion: 5. 10. 2018 Learning objectives: The student can mousavis@ethz.ch, 4th October 2018 Use the concept of state to model a system Model simple dynamical systems Linearize a non-linear system at an appropriately chosen point to derive an LTI system with A, B,C, D matrices Understand the notion of equilibrium points and can calculate them. The student is aware of the consequence of being in an equilibrium point Modeling Background: Dynamics Introduction Control systems I relies on some background knowledge in Dynamics to model mechanical systems. To enable you to solve the following exercise a short summary is provided. Dynamics are generally described in terms of accelerations following Newton s 2nd law. Here we distinguish between translational and rotational movements. The change in translational speed times the mass of the object being accelerated, is equal to the sum of the forces acting on the object as written in Eq. 1. Similarly, the change in rotational speed times the rotational inertia of the object being accelerated, is equal to the sum of the torques acting on the object as illustrated by Eq. 3. Translational dynamical equation: m ẍ(t) = i F i, (1) where x(t) denotes the position vector of the center of mass and is given by x(t) = x(t)e x + y(t)e y, (2) where e x, e y represent the base frame vectors with unit length of a two dimensional space. Rotational dynamical equation: J (A) θ(t) = i τ (A) i, (3) where J (A) is the so called moment of inertia with respect to an arbitrary point A. The above two equations should enable you to work with the following exercise problems.
Exercise 1 (Inverted Pendulum: Modeling, Linearization) Consider the mechanical system depicted in Figure 1. The objective of this control system is to keep the pendulum in the upright position. The system consists of a rigid bar of length L and mass m which is mounted with a fixed bearing at its lower end. A motor provides a torque τ(t). The moment of inertia of the bar with respect to point P is given by J (P ) = 1 3 ml2. Figure 1: Sketch of the inverted pendulum system with coordinate frame a) Derive the differential equations/equations of motion of the system using Newton s laws of motion. b) Classify the system into the following categories: linear/nonlinear, time-invariant/timevarying, static/dynamic, order/dimension of the system c) Define the states of the system and rewrite the differential equations in state-space form, i.e. ẋ = f(x, u). What is the control input u? d) Determine the equilibrium points of the system. e) We want to design a linear controller in order to achieve the control objective. Therefore we need a linearized model. Around which equilibrium point do we have to linearize the system? Linearize the system around this equilibrium point and provide the matrices A, B, C, D. Assume that you measure the angular velocity θ. Exercise 2 (Thermodynamic System: Temperature Control) Consider the tank (volume V) depicted in figure 2 which has an inlet (volumetric flow V in ) and an outlet (volumetric flow V out ). In order to synthesize a controller to regulate the temperature T R, we need to derive the governing differential equation. Consider the following assumptions: the fluid has a constant density ρ the fluid has a constant specific heat capacities c p, c v the flow throughout the system is stationary
T in, V in T R, V, c p, ρ T out, V out Figure 2: Temperature Control of a tank there is no heat loss the system is perfectly mixed the fluid is an ideal gas kinetic and potential energies can be neglected a) Formalize the above assumptions into mathematical expressions. b) Derive the differential equation governing T R using the energetic balance. Exercise 3 (Homework: Programming Exercise: Simulation) Consider the nonlinear system ẋ 1 (t) = x 2 (t) (4) ẋ 2 (t) = x 3 1(t) x 2 (t) + u(t) (5) a) Implement a time integration of the nonlinear system using Python. Simulate the system with zero input u(t) = 0 and nonzero initial condition x(0) = [ 1 1] T. Save the results as x_initial_resp. Simulate the system with zero initial condition and control input u(t) = 0.1 cos(2t). Save the results as x_forced_resp. [ T Simulate the system with x(0) = 1 1] and u(t) = 0.1 cos(2t). Save the results as x_mix. Does x_mix = x_initial_resp + x_forced_resp hold? Explain the result. b) Linearize the system around the equilibrium point using symbolic variables. State the matrices A and B. Conduct the same investigations as for the nonlinear system and compare the results.
Figure 3: Balancing cube. Figure 4: wheel. Inverted pendulum with a reaction Exercise 4 (Homework: Cubli: Modeling, Linearization) In this exercise, we will take a look at a simplified model of a Cubli (see https://www.youtube. com/watch?v=n_6p-1j551y). To keep things simple, we will assume that, unlike the real cubli in Figure 3, our cube rotates only in one dimension. To keep the cube in the desired upright position, we use a reaction wheel (those are normally used for satellite attitude control, check out https://en.wikipedia.org/wiki/reaction_wheel if you are interested) which is also visible in Figure 3. The simplified Cubli can be modeled as an inverted pendulum with a reaction wheel mounted at the tip of the pendulum. A sketch of such a model is shown in Figure 4. Angle θ is the angle of the tip of the pendulum and angle ϕ is the position of the reaction wheel w.r.t. to the tip of the pendulum. We define the counterclockwise direction to be the positive direction of rotation. Input to the system is the torque that you can apply to the reaction wheel T w. Parameters of the system are m (total mass of the system), l (distance from the supporting point on the ground to the center of gravity when angle θ = 0), J w (moment of inertia of the reaction wheel), J (moment of inertia of the whole system w.r.t to the supporting point on the ground). a) Derive the differential equations which describe the dynamics of the system. (Hint: Only the torque T w acts on the reaction wheel.) b) Find all equilibrium points. c) Rewrite your differential equations as first-order differential equations by introducing states x i. Linearize the system around the equilibrium point (θ = 0, ϕ = 0), i.e. find system matrices A, B, C and D. Assume that you can observe the output θ. d) Is the equilibrium point from the previous task stable? Can you justify your claims? Exercise 5 (Homework: Finance: Inventory Control) We are keeping an item stocked in a warehouse. If there is too little, we will run out of it soon (not preferred). If there is too much, there will be more cost of storage and misuse of capital (not preferred). Every morning there is the possibility to order new stock which is assumed to be immediately delivered. Depending on the demand of the product there are w items leaving the warehouse every evening, where w is a random variable with a given probability density function. The cost to order a new item is given by c; the revenue from a sold item is given by p > c. The cost of having too much stock or negative stock is given by some function r(x). The objective
is to find a control law such that the profit is maximized, however, we will only focus on the modelling part in the following. a) Define the state and the control input of your system. Are there any disturbances acting on the system? Are the any state/input constraints? What is the interpretation of x < 0? b) Derive the differential/difference equation governing the system. Classify your system into: linear/nonlinear, time invariant/time varying, static/dynamic, discrete time/continuous time, deterministic/stochastic. The above problem is a typical problem in the field of Optimal Control and can be solved using Dynamic Programming. Problem adapted from: Bertsekas, Dimitri P., et al. Dynamic programming and optimal control. Vol. 1. No. 3. Belmont, MA: Athena scientific, 2005, p. 3. and D Andrea, Raffaello, Dynamic Programming and Optimal Control, Lecture Notes: Lecture 1. Exercise 6 (Python: Simulation of a simple system) In this exercise, you will model some systems in Python in order to understand how to run and visualize a simulation. The system is represented by the following differential equation: ÿ(t) + y(t) 2 ẏ(t) + sin(y(t)) = u(t) How does your system respond when you put a step function as a system s input? Visualize the output y(t). How would you set the initial conditions to y(0) = 2, ẏ(0) = 0 and a delayed step input of 5 s? Run the simulation for 30 seconds and plot the results. Exercise 7 (Python: Simulation of a Spring-Mass 3D pendulum) In this exercise, you will model a relatively complex system in order to get more acquainted with the way solving differential equations in Python works and learn how to visualize a animated simulation. We will model the elastic pendulum shown in Figure 5. Its equations of motion (in 3 dimension) are given by: ẍ = ω2 (r l 0 ) x r ÿ = ω2 (r l 0 ) y r z = ω2 (r l 0 ) z g r where ω = k m and r = x 2 + y 2 + z 2. For system s parameters you can use: m = 0.1 kg, k = 10 N/m, l 0 = 1 m and g = 9.81m/s 2.
Figure 5: Schematic representation of the elastic pendulum system. Set the initial condition to x(0) = y(0) = 0 m, z(0) = 1 m and ẋ(0) = 0.1 m/s, ẏ(0) = ż(0) = 0 m/s and simulate the system. Aminate the simulation using the packages mpl_toolkits.mplot3d for 3D plotting and matplotlib.animation which provides animation utilities. You can find a 3d simulation tutorial at https://matplotlib.org/examples/animation/simple_3danim.html Try to plot also a persistent trajectory of the pendulum tip. Use different values of k. What do you expect as k grows very large? We show what the simulation looks like for a small k in figure 6a and a large k in figure 6b. We want to compare the exact solution to the solution obtained linearizing the system in one of the two equilibrium positions. Simulate the system after linearizing the dynamics at the bottom equilibrium position (x = 0, y = 0, z = l 0 mg/k, ẋ = 0, ẏ = 0, ż = 0). Is the approximation sufficiently good? Try different values for the spring stiffness and initial conditions. What do you observe?
(a) 3D pendulum with k = 10N/m. (b) 3D pendulum with k = 500N/m. Figure 6: Simulation examples: the orange line represents the trajectory followed by the pendulum tip prior to the capture of the image. Exercise 8 (Extra: Ball on a beam: Modeling, Linearization: (difficult)) In this exercise, we consider a simplified model of a Ball on a Plate/Beam system (see: https:// www.youtube.com/watch?v=j4omvlc_odw) as depicted in figure 7. The objective of this control system is to stabilize a ball at a certain location on the beam. The system consists of a rigid
beam which is mounted on a fixed bearing in its center of mass. The ball is modelled as a point mass m which slides without friction on the beam. A motor provides a torque τ(t). The beam has the moment of inertia J (C) with respect to its center of mass. Note that the coordinate frame is attached to the beam and is therefore time dependent. This has to be considered when taking the derivative with respect to time of the position x(t) = x(t)e r (t) + y(t)e θ (t). Figure 7: Ball on a plate Figure 8: Sketch of the system with coordinate frames a) Derive the differential equations/equations of motion of the system using Newton s laws of motion. Hint: The time derivatives of the coordinate frame base vectors are given by ė r = θe θ and ė θ = θe r. b) Classify the system into the following categories: linear/nonlinear, time-invariant/timevarying, static/dynamic, order/dimension of the system c) Define the states of the system and rewrite the differential equations in state-space form, i.e. ẋ = f(x, u). What is the control input u? Consider the following values of the system parameters: m = 1kg, g = 10m/s 2. Assume that the moment of inertia of the beam can be neglected, i.e. J (C) = 0 kg m 2. d) Linearize the system around a steady state setpoint such that x = x ss, θ ss = 0. Compute the steady state control input u ss and provide the matrices A, B, C, D of the linearized state space model. Assume that you measure the position x. Is J (C) 0 a good assumption?