[Bug] RTL_TYPE=1, VTOL get stuck in the air
Describe the bug
There is an edge case race condition that occurs when RTL is activated while the VTOL (in MC) is between the Home and Land waypoints.
To reproduce this issue, set RTL_TYPE to 1, create a flight plan similar to the one shown below. When the vehicle is between the Home and Land waypoints, trigger RTL. The vehicle must always be flying toward the Land waypoint as part of the mission.
This is a race condition, so it does not occur every time. However, if you repeat the test multiple times, there is a good chance that you will reproduce the issue.
Version of PX4 - main (commit 66bf7d5e959333d544f0f083afc3c29e62b20b44)
The first bug, No Valid Mission Available.
This occurs when the "No Valid Mission Available" error is displayed. While debugging and setting breakpoints, I noticed that the mission was indeed invalid at that point.
Brake-point image
Log
https://logs.px4.io/plot_app?log=eed65553-b985-4340-bb81-f30bc0cb8e80
Video:
https://github.com/user-attachments/assets/06635b1f-d44e-47d1-8db8-7241d2d1096a
I was able to fix this bug by adding updateMavlinkMission(); at the beginning of MissionBase::on_activation().
The second bug, VTOL Fixed-Wing Transition
Sometimes it occurs independently of the first bug, but once the first bug is fixed, it consistently occurs instead of the first bug. The same bug seems to be mentioned here: https://github.com/PX4/PX4-Autopilot/issues/24323
To reproduce the bug, the vehicle must be at the same altitude as the RTL altitude. In this case, the logic skips the first altitude adjustment condition (_needs_climbing) and enters the second one, triggering the fixed-wing (FW) transition.
Once the FW transition is triggered, the vehicle remains stuck in the air.
Edit: After further debugging, it appears that this bug is reproducible 100% of the time when the vehicle's current altitude is the same as the RTL altitude and the vehicle is closer to the landing waypoint than to the home position, regardless of the mission configuration.
Break-point image
Log
https://logs.px4.io/plot_app?log=104de51f-29a2-40af-b896-f0c498574fb5
Video
https://github.com/user-attachments/assets/f8ca4efb-db8d-4e0d-bae3-8023b64aa3c3
Conclusion
This VTOL fixed-wing transition during RTL contains questionable logic that needs to be verified.
Source: PX4/PX4-Autopilot