I have been searching in Redirecting to latest version of documentation and the web in general for a complete control loop architecture of the px4 without much success. So, I started looking at the source code, specially the mc_att_control_main.cpp and mc_pos_control_main.cpp files, and I came up with this.
Just be careful that the inner controllers (rate controllers) for position and angle are implemented with a PI+D structure, which means that the derivative component is not the related to the angular rates errors e(t), but to the plant output itself y(t).
I would say something like
u(t) = kp e(t) + ki int e(t) dt - kd d(y(t))/dt
Moreover, I would say that angular rates are controlled using a full PID controller.
From a theoretical point of view, let ui(k) be the integral term and e(k) the rate error at instant k, respectively, (represent by rate_i and rates_err in the code), let Ui(z) and E(z) be their z transforms, if implemented as you mentioned (the recursive definition that you called a “weird way”), we can apply the z transform to the formula
ui(k) = ui(k-1) + ki * dt * e(k)
to find out its transfer function
Ui(z)/E(z) = ki * dt * / (1 - z^(-1))
and that’s the same expression that is presented in the document that I mentioned.
As @alexh mentioned PID is compromised of PI+D [quote=“alexh, post:6, topic:3114”]
for position and angle are implemented with a PI+D structure, which means that the derivative component is not the related to the angular rates errors e(t)
Hi, I hope you made a progress in your project
I just want to make sure if you have validated your control architecture as we are trying to implement it in Simulink to tune the controller in a simulation… Are there other issues than the IP+D problems in the position and attitude loops?