Arduino-FOC-reaction-wheel-inverted-pendulum
Arduino-FOC-reaction-wheel-inverted-pendulum copied to clipboard
How to tune the LQR parameters precisely?
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
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
andk2
are necessary for stabilisation,k3
isn't really. So you can start by settingk3=0
- then tune
k1
andk2
. In my experiencek1
is more or less 10 times largerk2
. 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
. Thek3
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 thek3
is around 10 times smaller thank2
. With the higherk3
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 valuek3
and the pendulum is even more unstable than without it, this probably means that the sign ofk3
is wrong. :smile:
Good luck!
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.