opened 09:19AM - 25 Oct 22 UTC
bug
fixedwing
priority-critical
vtol
bug-report
## Describe the bug
The drone sometimes loiters around a wrong position and doe…sn't respect NAV_LOITER_RAD nor the desired turning direction.
I've observed it regularly on SITL VTOLs, and I could also break it once on a SITL plane. On VTOLs it's always the first HOLD command after a transition in mission mode which fucks up. The drone either holds around Home or at next Waypoint, but not at current position as it's supposed to. Resuming mission and then triggering Hold again works fine. Even the Hold in MC mode is affected by this, if triggered after a back transition.
On a pure FW drone I don't know what it takes to break, but it's possible as well. I've had one occurrence where the drone flew to the next WP instead of Loitering at current position.
Also, if this happens, then the NAV_LOITER_RAD is ignored and the drone is just flying with max bank angle.
The bug is present in both v1.13 and current main.
## To Reproduce
Steps to reproduce the behavior:
1. `make px4_sitl gazebo_standard_vtol`
2. Upload a mission containing a transition, e.g. the one here:
[Zurich FT loiter bug.zip](https://github.com/PX4/PX4-Autopilot/files/9858850/Zurich.FT.loiter.bug.zip)
3. Launch the mission. Trigger Hold at some point after the front transition.
4. See error
5. Feel free to resume mission, trigger Hold again, and observe that it works correctly again. Then resume mission, launch a back transition via QGC interface, and Hold again -> broken again.
## Expected behavior
The drone should loiter around the point where the HOLD command was sent.
## Log Files and Screenshots
Log on v1.13 (roughly, our fork contains some minor changes but nothing which affects this) where the drone more or less returns home for Loiter : https://logs.px4.io/plot_app?log=f24d5c4e-b495-4d9b-93dc-b6e321beda15
Log on upstream where I consistently managed to break the logic after transitioning, even after back transitions : https://logs.px4.io/plot_app?log=4e307d13-c94a-4543-a625-3e54d88ae0b9
Log on upstream with tailsitter. Same behaviour as with standard VTOL: https://logs.px4.io/plot_app?log=f1441279-1e2f-42e1-8599-b17ff4881f19
Log on upstream on a FW plane where I managed once (on the second trigger) to break the logic, but not the first time nor any time after: https://logs.px4.io/plot_app?log=683f7ffa-58c3-4860-ae32-debca6c1433e
Log on upstream on a MC drone where I couldn't break it (not sure if nothing is broken for MC or if I just haven't found how to break it): https://logs.px4.io/plot_app?log=d2fafa11-a5fa-4bed-a6ed-108749353267
Add screenshots to help explain your problem.

I've found so far that during the Loiter which goes badly the position_controller_status/type stays at 0 instead of being the usual 2.
## Drone (please complete the following information):
I haven't dared to check on a real drone yet. The following SITL models have so far found to be affected:
- gazebo_standard_vtol
- gazebo_tailsitter
- gazebo_plane