- Calculate the LQR gain matrix using the 'lqr' function, with 'Al', 'Bd', 'Q', and 'R' as inputs. This function will return the gain matrix 'K', among other things.
How to apply a logic to LQR controller to get the reduced responses ?
8 views (last 30 days)
Show older comments
Hello everyone,
I have a uncontrolled response and controlled response of "u and du" and trying to apply a LQR controller to reduce the "u and du". But Im not getting an idea how to apply it as a feedback logic. Please suggest me to correct it.
Thank you
0 Comments
Answers (1)
Hari
on 4 Feb 2024
Hi Tappiti Chandrasekhar,
I understand that you are trying to implement a Linear Quadratic Regulator (LQR) controller to reduce the responses 'u' and 'du'. You have the uncontrolled responses and want to apply the LQR as a feedback control to achieve the controlled response.
Assuming that 'Al' and 'Bd' are the system and input matrices respectively, and 'Ed1', 'Ed2', 'ugv', and 'ugd' are disturbance or reference inputs, you would apply the LQR controller by computing the gain matrix 'K' and then using it to generate the control input 'ptra' as negative feedback of the state 'u'.
Here is an example of how you might apply the LQR controller:
% Calculate the LQR gain matrix
[K, S, e] = lqr(Al, Bd, Q, R);
2. Initialize your state vector 'u' and its derivative 'du' to zero vectors of appropriate sizes. Also, initialize your control input vector 'ptra' to a zero vector.
% Initialize state and control input vectors
u = zeros(size(Al,1), long);
du = zeros(size(Al,1), long);
ptra = zeros(long, 1);
3. Now, create a for loop that runs from 1 to one less than the variable 'long'. Inside this loop, calculate the control input for each iteration as the negative product of the gain matrix 'K' and the state vector 'u' at the current iteration.
4. Update the state vector 'u' at the next time step using the system matrix 'Al', the control input matrix 'Bd' with the current control input, and add the effects of the disturbances 'Ed1', 'Ed2', 'ugv', and 'ugd'. Similarly, update the derivative of the state vector 'du' at the next time step using the same formula as for 'u'.
For understanding the LQR controller design, refer to the documentation of the "lqr" function https://www.mathworks.com/help/control/ref/lqr.html
To learn more about state-space models and feedback control, refer the documentation on "State-Space Models" https://www.mathworks.com/help/control/ug/state-space-models.html
Hope this helps!
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!