YaChienChang / Neural-Lyapunov-Control

Learning Lyapunov functions and control policies of nonlinear dynamical systems
117 stars 31 forks source link

LQR solution for the Inverted_pendulum example #13

Closed KirolosRomany25 closed 1 year ago

KirolosRomany25 commented 1 year ago

Hello, I tried to calculate the LQR solution for the linearized model arround the origin, but I got different values from what you have in the published code, [-23.58639732, -5.31421063], and when I try to run your code with the LQR solution that I have found, the search for the Lyapunov function, which guarantees the stability of the system, does not converge to a valid function. I also publish the matlab code that I used to find the LQR solutions, using MATLAB:

%%%%%%%%%%% G = 9.81; l = 0.5; m = 0.15;
b = 0.1;

d = -b/(m*l*l);
c = G/l

A=[ 0, 1;
      c, d ]
B=[ 0;
  1/(m*l*l)
      ]
R=eye
Q=eye(2,2)
[K,S,P] = lqr(A,B,Q,R)

%%%%%%%%%%%%

the LQR gain is [1.9773 0.9762]

So can you please tell me how did you get the LQR values?

Thank you

jlwu002 commented 8 months ago

Hi, I encountered the same issue. I found out that I can get the result in the paper if I remove the parentheses in the denominator. The result I get is the same as your MATLAB result. #14