Could PID tuning be implemented in on-demand way?

Hello,

Currently I can see two ways for APM:Copter to tune PIDs in mid air: via CH6 and by using autotune feature.

What if it could be implemented to work in on-demand way? Imagine pilot have just build copter. It has never been tuned for PIDs or some tuning progress flag has been reset. Then pilot starts motors, takes it off the ground and controls copter with sticks.

And then while it performing some actions of flight plan (not specific for tuning), software is evaluating actions and frame response (as id does while auto-tuning) and applying new corrections to PID values. It may take some time to have PID tuned in a good way, maybe not a single flight. Copter will fly better and better. And then at some moment it will be finally tuned.

What do you think on it?

I have heard this is what DJI does. It should be possible but I don’t thing it is as simple as it sounds or easy or predictable. What if it learns it wrong.

The Ardupilot Plane Autotune mode works exactly like that: you give sharp (>80%) stick inputs, and it learns the frame response. Maybe it is possible to adapt that code to Copter?

Thank you Arthur! Will try to look at sources.

I agree, it could be not so easy to implement in a way that it would be really usable. But it may worth to try. That’s for your question about wrong tuned PIDs, I believe it’s not a problem to reset some flag and to restart learning process from begin.