LQR controller

Discussions and questions about the Crazyflie Nano Quadcopter
Post Reply
Zafer
Beginner
Posts: 6
Joined: Wed Apr 27, 2022 7:43 am

LQR controller

Post by Zafer »

I would like to implement my own controllers such as an LQR controller. Is this possible? Can I directly control the voltage sent to the motors or the motor speeds? Is there a way to 'turn off' the already implemented PID controllers and replace that with something of my own?
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: LQR controller

Post by kimberly »

Hi!

So you would like to do this all onboard right? Anything is possible as it is opensource :D but it will require hacking as there is no standard way of doing things.

The absolute lowest control of the motors from the STM32 is the functions that happen in power_distribution_stock.c, and from there you could check out the other files in /src/modules/src/ folder like controller_pid, position_controller_pid and attitude_pid_controller. If you use vscode you can usually trace the line of code that goes from setpoints all the way to the motor distributions.

Happy hacking!
Zafer
Beginner
Posts: 6
Joined: Wed Apr 27, 2022 7:43 am

Re: LQR controller

Post by Zafer »

Thank you very much!

Well it makes sense to me to do it onboard, I don't see a practical alternative. Do you think it's possible to do it offboard?
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: LQR controller

Post by kimberly »

It should be possible, but I wouldn't advise to control the motorspeed directly due to the communication latency. I think the LQR controller should have attitude rate as output and you should send those to the attitude rate PID controller on the crazyflie.
Zafer
Beginner
Posts: 6
Joined: Wed Apr 27, 2022 7:43 am

Re: LQR controller

Post by Zafer »

Ah I see, I will do it onboard then. Thank you very much
Post Reply