Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to tune the LQR parameters precisely? #5

Open
weiminshen99 opened this issue Sep 3, 2023 · 2 comments
Open

How to tune the LQR parameters precisely? #5

weiminshen99 opened this issue Sep 3, 2023 · 2 comments

Comments

@weiminshen99
Copy link

Dear Antun,

Thank you so much for this amazing project and it is very inspiring !!

I made a similar system that is almost working (please see https://youtube.com/shorts/L6I1zPEigmI?feature=share), but I don't know to tune the LQR parameters precisely so to make it completely stabilize. Could you please give me some advice? Thanks!

-- Wingman

@askuric
Copy link
Member

askuric commented Sep 16, 2023

Hey @weiminshen99 ,

here is a community post from some time ago that might be helpful: https://community.simplefoc.com/t/self-balancing-robot/343/24?u=antun_skuric

Basically, if you have such state space control algorithm:

Voltage = k1*angle +k2*angular_velocity +k3*motor_velocity;

tuning procedure

  • k1 and k2 are necessary for stabilisation, k3 isn't really. So you can start by setting k3=0
  • then tune k1 and k2. In my experience k1 is more or less 10 times larger k2. The expected behavior that you're searching to get is that the robot almost stays upright, but the motor never stops turning. And at some point the motor reaches its maximal velocity and then the robot falls (as it can no longer generate acceleration in that direction)
  • Once you've reached this behavior you can start adding a small value of k3. The k3 penalizes the motor velocity so the motor will try to stop as soon as it can (as soon as the pendulum is stable and upright). In my experience the k3 is around 10 times smaller than k2. With the higher k3 you will add more importance to the motor velocity so you’ll see the effect visually.
  • Now make sure that the sign of the k3 is good. If you add a small value k3 and the pendulum is even more unstable than without it, this probably means that the sign of k3 is wrong. 😄

Good luck!

@weiminshen99
Copy link
Author

Hi, Antun,

Thank you so much for your reply and advices! I will try them out and let you know the results.

By the way, the "Self-Balancing Robot" applications are very cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants