Problem has been described here: https://forum.librepilot.org/index.php?topic=3285.msg22659#msg22659
I have also encountered this problem. Key is that velocity desired is set to +0.6m/s
It looks like the sign is wrong. Since this positive value is used to set "controlDown.UpdateVelocitySetpoint(velocity_down);" in vtolautotakeoffcontroller.cpp
Analysis of my flight logs shows that the failed autotakeoff is using 0.6 for the setpoint. However, the autotakeoff sequence that succeeds is using a negative value for the setpoint.
The first time autotakeoff is engaged, the ObjectiveUpdated function is called with the mOverride parameter set to true.
The second time autotakeoff is started (after unarm-arm), mOverride has been set to false.
This time, the code path is different, setting the velocity setpoints to values defined in the ModeParameters.
This probably explains why the quad sometimes takes off with a slight sideways motion. North-East velocity setpoints are not set to 0 in that code path.
A patch will follow. I haven't flight tested this yet. But will try in the near future.
Someone else may test the patch as well.
autotakeoff flight mode
Flight tested a quad with the patch from this PR.
I performed about 6 automated takeoff and landings. All of them went flawlessly.
So it looks like the patch is an improvement. However more testing is certainly needed.