Position hold or zero velocity?

During position hold with a px4flow camera, does the PX4 software follow a constant position set point, or a zero velocity set point? It seems that without external disturbances, both of these approaches should result in the same behavior which is essentially position holding.

I found the function control_position(float dt) in the mc_pos_control_main.cpp file, which seems to use either velocity set points or position set points to compute a thrust set point, but I am having a hard time determining when one approach is used over the other.

I appreciate if anyone can point me in the right direction.



mc_pos_control does position control, i.e. holds a position setpoint when the sticks are not touched. This is done in a cascaded fashion: A P controller computes velocity setpoints from position error which is fed to the PID velocity controller.

The source of the estimated vehicle position which mc_pos_control uses is irrelevant. The position estimator (LPE or EKF2) fuse flow measurements into the state estimate (which includes vehicle position and velocity). This is then used by mc_pos_control, vehicle position is used to compute position error, vehicle velocity is used to compute velocity error.

Thanks for clarifying Nicholas,

I assume this approach works better than simply following a zero velocity set point even indoors?
I tried to achieve similar results (quad absolutely still) with my own quad and flight controller by following a zero velocity command in the horizontal plane but this doesn’t seem to work very well. It tends to drift every now and then for some reason.

Maybe I will try estimating the position and use that to compute a velocity command.

Thanks again!


If you only try to control velocity to zero, drift is exactly what I would expect to see. Any horizontal velocity observed is controlled back to zero, but the vehicle of course already moved a certain distance. With only velocity control, there is nothing that would control the vehicle back to its former position.

So what about in gps denied environments such as this video:

When he lets go of the controller, is position hold being used? If so how is the position set point being estimated if there are no measurements of position?

The position controller does not care how the estimated position and velocity are attained. It subscribes to the appropriate topic and controls on that. It’s the position estimator’s (EKF2 or LPE) job to generate those position and velocity estimates.
In the case of flow-only flight, the position estimator uses flow measurements (which are effectively velocity measurements) to estimate vehicle position and velocity. The estimated position is essentially the integrated velocity measurements. Thus, even with only velocity measurements, position control (and not just zero-velocity control) can be achieved.

To achieve this, think of the following situation. The vehicle is hovering in position control with flow as the only sensor. You now push the vehicle to the side. If you were controlling on the estimated/measured vehicle velocity, the vehicle would fight you while you’re pushing it, and then stand still.
In the above described behavior, however, the estimator will measure the displacement and thus report the offset position estimate to the position controller, which will then try to control the vehicle back to its original position.

I hope that explanation clears things up for you.

Thanks Nicholas, that clears it up. I would expect integrating the velocity would result in drift or error in the position estimate over time, but judging by the video there seems to be very little drift, if any, which is impressive.



I didn’t mean to imply that there is no drift. You are absolutely right that if you only have velocity measurements, you will incur drift over time. What I meant to say was that the position controller will bring you back to the setpoint (up to drift induced position estimation errors), if pushed away from the setpoint. This would not happen if you were only controlling velocity to zero.