Trajectory Setpoint and Vehicle local position topics

Hi everone I’m doing an university project and I have to insert a HOSM controller in the PX4 firmware for multicoter drones, in order to do this I need some measurements and I’m not fully understanding where the drone states are.
I’ve seen that measurements comes from EKF, accelerometers, IMU sensor etc. but I also noticed that the internal PID controller only refers to two topics to compute the error:

The thing that i would like to know is if all the variables inside these topics (like position,speed,accelleration,jerk,orientation) are updated internally looking at the sensor measurements or if only few of them are updated.
Then I also noticed that for local_pos measurements in the mc_pos_module the local_position_setpoint is adjusted and that the acceleration_setpoint is derived from speed.

Can anyone clarify me all this mess?