bitcraze / crazyflie-simulation

MIT License
64 stars 27 forks source link

Model Predictive Controller #46

Closed nikhil-sethi closed 1 year ago

nikhil-sethi commented 1 year ago

Hey everyone, Just added an Model predictive controller that I've been working on. It's not great but works. Currently I've just been testing with a single static setpoint but hopefully with a full trajectory in the future. Other issues as of yet:

  1. The yaw in the setpoint isn't followed too well. I've tried playing with the terminal cost and the Q matrix but not much has changed. At the setpoint, the yaw accelerates over time and therefore becomes unstable. It would be cool if someone more experienced could also look into this.
  2. The optimization gets unstable when the RPM (control action) ranges are wide. I've had to restrict it to a narrow band which also means it doesn't work for aggressive flight as of yet. I do expect this to change with better tuning though.
  3. I did not estimate the Cd value in the dynamics model using data. It is just something I've tuned manually. I also suspect that with better estimation, the yaw issue might become better.

Let me know what you think!

Demo

knmcguire commented 1 year ago

Hi! thanks a lot for this!

We need to discuss internally what the purpose of this repository is. The general idea is to keep it very baseline that enables flight, so that others can fork it and implement their own stuff easily. Let me discuss internally if this repository is the right place for such a contribution.

knmcguire commented 1 year ago

Sorry for the late reply. I think it is better to leave any special controllers out of this repo to not increase our maintenance burden. This should be just about the simulation and not the controllers (although the controller should be good enough to make it fly). MPC controller is too specialized.

I hope you understand!