Position velocity control structure px4 release 1.10 (stable))

Hello @bresch, @JulianOes
I gone through the mc_position and mc_attitude control source code for the px4 release 1.10 (stable).
As per the picture in the documentation it says that there is only a “proportional gain” block between positon control that generates ‘velocity_setpoints’ and velocity controller whose input is velocity_setpoints. The picture is

But, when i was going through the mc_position control source code i could see the following part
The part highlighted shows that there is a feedback from vel_sp that gets added to the generated vel_sp_position and makes vel_sp. this confuses me if there is only proportional gain block there why is this feedback there which is like some sort of integrator. Please throw some light on what is the actual controller structure followed here.

Hi @Ranjeet,

You’re right, there is actually an optional feedforward being added to the output of the position controller. This is missing on the diagram and should be added.
The optional feedforward usually comes directly from a trajectory generator and is the derivative of the position reference signal.

On v1.11 there is also an acceleration feedforward, improving greatly velocity tracking.

thanks @bresch for the clarification. So if some step signal is given as reference position to reach, then “vel_sp” which is derivative of the position reference signal will be zero and this step will have no effect on final velocity set-points that go in velocity controller? Am i correct or still missing something?
One more thing I would like to ask is that where is the acceleration feedforwarded to ? Is it added to velocity_sp_position or is there another acceleration controller in V1.11?

@Ranjeet It really depends which setpoint you send to the controller: If you only send a position setpoint, there will be no feedforward automatically computed. However, if you give it a position, velocity and acceleration setpoints, the controller will use the velocity and acceleration setpoints as feedforwards.

Let’s take the example of the mission mode:
In mission (auto) mode, the setpoints are generated in a FlightTask using a jerk-limited trajectory generator. In this case, the position/vel/acc references are continuous and can be safely given to the position/velocity controller.

Regarding the acceleration setpoint, it is added as a feedforward to the output of the velocity controller, before being transformed into thrust. We can summarize the data flow as follows:

pos_sp -> pos (P) controller -> add vel FF (optional) -> vel (PID) controller -> add acc FF (optional) -> convert to thrust -> convert to attitude setpoint -> attitude (P) controller -> rate (PID) controller -> control allocation -> motors

Hope it helped.

Thanks a lot @bresch, your explanation really cleared many doubts.
Really appreciate you for the time you took to explain. Thank you :slightly_smiling_face:

@Ranjeet You’re welcome, could you please accept my answer to mark the question solved?
I opened an issue in the devguide to update the diagram: https://github.com/PX4/Devguide/issues/1070

@bresch, I have marked your answer as solution to my query. :+1: