MC position control

Dear all,
I saw that in MC_position_cointrol.cpp, there is a function called control_manual(dt), in which the postion setpoint (_pos_sp) is caluclated according to the current control status:

reset_pos_sp function resets the setpoint to current position (_pos). However, I also saw that, in the same control_manual(dt) function, the setpoints are reset again if the copter is not engaged in position control mode. I just confused why the setpoints are set twice both in position control engaged and non-engaged scenario. Which is the final setpoint the copter tends to maintain?

@doctorluhang reset_pos_sp() just has an effect it the flag _reset_pos_sp is set.
So normally the flag is not set and the function does nothing. I agree that this could be done better
feel free to contribute your code.

Oh, right! Thanks for the instructions. There is a flags so _pos_sp is not updated at every reset, which tricks me…