rahulk200013 / Self-Balancing-Bot

A Self-Balancing robot to balance and travel with the help of only two wheels. The same is implemented using Linear Quadratic Regulator (LQR) as well as Cascaded PID as well
1 stars 1 forks source link

Question about the difference between Cascade PID and LQR #1

Open South-River opened 2 years ago

South-River commented 2 years ago

Hello! I'm also making a self balance robot, but I'm wondering the difference between Cascade PID and LQR controller. image image Like these two picture, Cascade PID seems just a different form of LQR(e(k) means the error of velocity)? And one more question I want to ask is that how to tune LQR controller. My robot also use LQR controller, but it works like this:( VID_20220626_185131 (2) I tried to reduce the robot gyro's param's value, it became smooth but not robust:(.

rahulk200013 commented 2 years ago

In terms of mathematics, LQR and PID are kind of the same thing. But still there is a big difference in the way you implement them. The reference of the error of next stage is decided based on the output of previous stage in cascaded PID and then the constants needs to be find out. In case of LQR there is just one linear equation as you shown in the picture. When you implement LQR, you just implement this single equation in the code. Doesn't matter how many state variable you are trying to control. Wheras in PID as the number of state variables increase, the nber of equations and constants to tune also increase kind of exponentially.

Now coming to the last part of your question, tuning of LQR controller is done on computer in softwares like Matlab, etc where you try to give different weightages to different state variables depending on what kind of performance you want to get out of your robot. There is a dedicated function in Matlab to which you give the mathematical model, your weightages and it will give you the value of constants that you need to put in the final equation and implement in the code. In Matlab you can simulate the robot in graphical form using the mathematical model and the constants you calculate.