Hi. i’m analyzing the source PositionControl.cpp from mc_pos_control.
I have some questions about this part.
Is that right _vel_sp comes from the Velocity Setpoint computed by the Trajectory Generator?
I undersand the feed-forward velocity setpoint improve tracking position.
but I just want to know why track well mathematically or logically.
I would be grateful if you could review these questions and provide answers.
Let me ping @MaEtUgR for this one.
I don’t know about where the velocity setpoint comes from, but I can tell you why it improves the performance.
Imagine that you want to track a position setpoint such as a linear ramp.
A linear ramp is just a linearly increasing position setpoint which can then be tracked with a constant velocity:
Linear ramp expression (on the position along the x axis for example)
p_x,d = v_x,d * t + p_x0,d
The first term is the desired position you want to track, the second the desired constant velocity that achieve such position, the third I just time and lastly the fourth is an arbitrary offset.
Now, the position controller applies a simple P control, and it’s outputs is the drone velocity.
So, the drone velocity is
v_x = P*(p_x,d - p_x)
With the first term the commanded drone velocity, the second the P Gain and the last two the desired position and the actual position, respectively.
If you see the formula of the ramp, the drone needs a constant NON ZERO velocity. Therefore, looking at the second formula, the only way to have a non zero v_x is tho have a discrepancy between the desired position and the actual one!
Conclusion? As it is, the velocity is kept constant at the cost of a non perfect tracking of the position. Because the drone moves only if there is a position error (this is a property of the P controller)
Solution? If you know the desired velocity v_x,d, then just add it to the P controller. Feed forward it!
v_x = P*(p_x,d - p_x) + v_x,d
The desired velocity is now imposed by the feed forward while the P control zeros the position error.
Thank you! It was very helpful! @Benja