Pole Placement for the Inverted Pendulum on a Cart [Control Bootcamp]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay welcome back so now we're ready to design a control law to stabilize the inverted pendulum on a cart okay I move the picture down here so I could have some breathing room last time we took the nonlinear system describing the Lagrangian mechanics of this inverted cart on a pendulum on a cart problem we simulated it then we linearized about the pendulum up position to obtain an a matrix and the B matrix I didn't go through all of the math but that's kind of basic physics oh so I showed you that there is a linearization and then we checked that the rank of the controllability matrix was in fact four which means that we span all of our state space with this controllability subspace meaning that the system is controllable and of course now we know that if the system is controllable then with full state feedback by measuring the full state of the position and velocity of the cart and the pendulum so this full state then I can design this closed-loop system so that the eigenvalues are anywhere I want okay and so now what we're going to use is the place command in MATLAB so we're literally going to say K equals place and we're going to give it a B and we're going to give it a vector of desired eigen values I okay and so let's do this we knew that this system if I just look at the eye of a we know that there's this unstable eigen value so let's just manually say I want my eigen values to be like negative 1 negative 1 point 1 negative 1 point 2 and negative 1 point 3 so let's say i negative 1 point 1 negative 1 point 2 negative 1 point 3 and negative 1 point 4 so my desired eigen values I want to cook up a K so that my closed-loop system has those eigen values ok and this seems like a lot to ask right I just pulled these out of a hat they're stable eigenvalues should be great and hit enter okay so those are my eggs and now I'm going to type in K equals place a be eggs it's that simple in MATLAB it is so simple to cook up a controller k so that it has the poles the eigenvalues where you want them to be so that's my controller K it's just a matrix and now if I look at eggs of a minus B times K and I'm hoping that it's minus K and not plus K we'll try this I of a minus B times K low and behold I get exactly the eigenvalues that I specified everyone follow that let me just let me expand this a little bit okay so we said I equal this we specified the eigenvalues we wanted and then all we did was we said K equals place a bi X this is a built in MATLAB function that tells me what is the controller K in this proportional feedback controller that will shape the closed-loop eigenvalues to be the eyes that I specified and this is that K so now I just say I want to verify that this closed-loop system does in fact have the right eigen values so I'm going to do a minus B times K and the closed-loop system a minus B times K does in fact have these desired eigenvalues so it's really that simple to place your eigen values where you want with closed-loop feedback if your system is controllable if your system was not controllable you wouldn't be able to do this so we get this because our system is controllable because force on the cart is a good control that allows me the authority to stabilize the pendulum okay okay excellent and so now once we have this we can actually try to use this K matrix so I'm just going to type K again so we can try to use this K gain matrix to actually stabilize the nonlinear system which is really going to be fun okay so I'm going to go back to my script okay and I have a bunch of different pull locations that we're going to try but we're not going to do that yet so let me just comment those comment those out let me see if I can remember how to do this in MATLAB okay I'm going to comment those out and I'm going to try a few different pole placements a few different placements of the eigenvalues because we're going to play around like how where do I want to put the eigenvalues of this closed-loop system we're going to try a bunch of different ones but for now let's just try this one minus 0.3 minus 0.4 minus 0.5 minus point six more or less I'm just pulling it out of a hat okay so I do this place k equals place a be P where P is my list of eigenvalues and then I'm going to essentially integrate the same vector field that same cart penned vector field except in the U position where the control is before I had 0 I had zero control now I'm going to plug in minus K times my state - a reference value okay and so basically what I want is why my state so I'm I don't know why but I'm calling this I'm calling this a vector Y and D DT of this is y of f of Y and all of these become wise whatever in MATLAB what I want is for my state I want this to approach a reference value of 1 0 PI 0 okay and so what that means is I want this thing to walk over 2x equals 1 and keep the pendulum in the vertical position and with that K gain matrix I should be able to do this because I've stabilized my system okay so let's try this out and again I can just run this code so I am trying to move this up and at the end of my code I'm going to draw the solution so once I run the simulation I'm going to plot the pendulum doing what I want it to do okay so let's do pull place cart pets that's my script I'm going to hit enter I'm going to hope for the best oh it went off the screen but then it came back okay so let's see if I can do better I think I need to integrate for longer try this one more time it's not the most impressive okay so it starts vertical that a little ways off it actually goes off screen but then it very slowly comes back to where I told it this reference value of 1 in the exposition zero velocity PI in the vertical in the theta Direction zero velocity so this pole placement did stabilize and move the system over which is pretty cool okay so it actually worked but it took forever to walk over there and I started in an initial condition I think it x equals minus 4 or something like that looks let's see yeah so my initial condition was X was minus 3 and it was a little bit off vertical PI plus point 1 so let's say I want to make this more aggressive I want to make it faster to move over to the right so what would I do to these poles these eigenvalues i call them poles we people call them poles or eigenvalues they're the same thing what would I do to these to make them faster so this thing is more aggressive well I could move them farther into the left half plane I can make them have a more negative real part that should make them fast Derr and more aggressive so let's try this one okay so I'm just making them more negative negative 1 negative 1 point 1 negative 1 point 2 negative 1 point 3 so this is more aggressive eigenvalue placement I should have faster faster convergence let's try this out pole place cart pen who's going to run very fast and it goes right where it's supposed to so it didn't go off screen it didn't barely control it did its control pretty fast which is nice that's what we wanted to do so moving the eigenvalues into the left half-plane farther seemed to be a good thing okay now could we just keep doing this indefinitely what if we do what if we make them more stable okay so here I'm going to make you know minus 2 minus 2 point 1 and so on and so forth so disease or even more aggressive let's try this maybe this will just go right to the point and be good okay really fast okay didn't take any time getting there it was very aggressive but you can also see it started getting pretty jerky right it's probably pretty expensive it's really cranking on these these tires to get this thing moving over there so if I don't have a big engine or big motor in here I might not be able to realize this controller I'm assuming if I plotted you to be really big okay because those things really Hollen and I can go even farther I can go even farther let's keep going one more one more level of aggressive so I'm moving it even farther into the left half-plane and I'm going to decrease my time I don't need to integrate 230 any more you can see super jerky okay and I'm not going to show you this but if I increase if I move those pulled any farther into the left half-plane the system actually breaks it becomes unstable the nonlinear dynamics are unstable if I move my pole of the linearized system too far into the left half plane so it's interesting actually we think of the eigenvalues being farther in the left half plane having a more negative real part as being more stable what that really means is it's faster those dynamics are faster this thing will approach its desired equilibrium faster but it's actually less robust the farther I push these eigenvalues into the left half plane in a lot of cases in this case it becomes less robust we're kind of on this nice edge where we're really throwing the system around and these non-linear the nonlinear system might not act exactly like the linear system where we built our controller and so it's some super aggressive control it'll actually break and so there it turns out there's a sweet spot an ideal set of eigenvalues that we can place for this system that will have the best trade-off of performance of how fast the system moves to where it wants to move and not spending too much control effort in doing so okay and so that's what we're going to work on next it's called the linear quadratic regulator okay this is lqr and it's one of the most important results in optimal control theory it's essentially gives you the optimal gain matrix K that balances how fast you stabilize your state and how much control energy you're expending to do so so it's kind of a sweet spot of pole placements and again in MATLAB super simple one-line and MATLAB code okay so that's where we're going next
Info
Channel: Steve Brunton
Views: 61,864
Rating: undefined out of 5
Keywords: Control, control theory, Linear algebra, Eigenvalues, Closed-loop, Feedback, Controllability, Reachability, Applied Math, Matlab, SVD, Singular value decomposition, Controllability Gramian, Gramian, pole placement, place
Id: M_jchYsTZvM
Channel Id: undefined
Length: 12min 54sec (774 seconds)
Published: Sun Jan 29 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.