markusgritsch / SilF4ware

SilF4ware -- an STM32F4 port of SilverWare
https://www.rcgroups.com/forums/showthread.php?3294959-SilF4ware-an-STM32F4-port-of-SilverWare
MIT License
27 stars 10 forks source link

Drones do not follow a FOPDT model #1

Open Quick-Flash opened 2 years ago

Quick-Flash commented 2 years ago

I've been looking at your smith predictor code, but I eventually came to a conclusion, drones (at least in the pitch and roll axis) do not follow a FOPDT model. They are better modeled by a leaky integral plus dead time model. That is because when pidsum is set high and then low, the drone will not stop itself from rotating, and will only slowly slow down. https://github.com/markusgritsch/SilF4ware/blob/021d409bd6afaad170c3f724d0a8e2a1037e36c5/SilF4ware/control.c#L235

image A model that follows an integral of the pidsum with deadtime that leaks towards the actual gyro value will be a better model of the system. An integrating model with no leaking will quickly become wildly inaccurate, thus the need for leaking.

This link includes useful information about the differences between FOPDT and IPDT models. https://controlguru.com/recognizing-integrating-non-self-regulating-process-behavior/

markusgritsch commented 2 years ago

Hi Kevin,

when I experimented with the Smith Predictor code, I came to the conclusion, that it has no beneficial effect.

Have you tried your suggested Smith Predictor model in EmuFlight?

Cheers, Markus

Quick-Flash commented 2 years ago

Hi Kevin,

when I experimented with the Smith Predictor code, I came to the conclusion, that it has no beneficial effect.

Have you tried your suggested Smith Predictor model in EmuFlight?

Cheers, Markus

Markus,

I have not yet tried this new model. I'm hoping to get some blackbox data to help me when creating a model, and weather has been quite snowy recently. I think it might work better than just the simple delay model that I had used. However, the simple delay model is pretty good at modeling the delay from gyro filtering, and as such if you are only modeling the gyro and its output it can do a decent job at removing delay from filtering. For a model of the entire system an approach more like yours is better.

I do find it odd that you found no benefit. From logs I've taken I can see how the smith predictor is able to remove some of the filtering delay and bring the signal closer to the raw signal (but still filtered).

Other places I have considered the smith predictor is on the motors where a FOPDT model is quite appropriate. I really do feel like the whole torque boost code that is in some silverware based code bases is really a poor attempt at a FOPDT model for motors.

Cheers, Kevin

Quick-Flash commented 2 years ago

@markusgritsch it turns out that a leaky integrator plus deadtime model is really just going to be similar to a first order plus deadtime model. https://en.wikipedia.org/wiki/Leaky_integrator#/media/File:Leakyintegrator.png image

What I'm finding odd is how in short time scales the system will act like integrator plus deadtime, but in very long scales it will act like a first order plus deadtime as the drag on the drone will slowly get the drone to stop spinning. So perhaps a FOPDT model is the way to go, but with a very long filter time on the pt1 filter. Perhaps the leaky integral method will be easier to approximate the system and find working numbers. Seems somewhat tricky to get a good model, but I'll let you know what I come up with and if it seems to work.