PX4-Autopilot icon indicating copy to clipboard operation
PX4-Autopilot copied to clipboard

Enable RTL even if landed

Open junwoo091400 opened this issue 3 years ago • 2 comments

Describe problem solved by this pull request

While testing pacakge delivery mission with RTL as one of the mission items, I noticed the following:

  1. RTL doesn't work if the vehicle is landed
  2. As soon as the vehicle lands, the land disarm timeout COM_DISARM_LAND isn't taken into account and vehicle disarms rightaway

Describe your solution

First, I added a condition where if the RTL destination is not where we are at (with the error margin of NAV_ACC_RAD in meters), to keep the original behavior of not doing RTL in case: we are landed at the RTL destination, but allowing RTL if the destination isn't where the vehicle is landed at.

This case can easily be imagined with a package delivery mission, where an operator puts LAND, RTL mission items in sequence and expects the vehicle to return automatically. With previous code, it would never allow RTL to happen since vehicle was landed. In this case, operator may lose the vehicle :exploding_head:

Second, during the test I found edge case where the vehicle's nav_state comes out of the NAVIGATION_STATE_AUTO_MISSION while landed, and enters the condition where automatic disarming while landed starts to count (hysteresis). Here, since the flag for the hysteresis was never getting reset to False.

And the hysteresis object is shared by two different "disarm when laded" conditions (Preflight & generic land after flight cases), the previous Preflight case' would already set the internal requested state to True (until the moment vehicle took off), and when vehicle landed again, there of course has been more than ~10 seconds (COM_DISARM_LAND value) of time in between, so the vehicle disarmed immediately.

I solved this by setting the state to False if we don't enter any of the hysteresis conditions.

Test data / coverage

Before the change: image

After the change: image Vehicle doesn't disarm after landing, and RTLs automatically as part of the mission.

How to test

  1. Build SITL make px4_sitl jmavsim HEADLESS=1

  2. Upload the Mission via QGC and execute the mission. Here's the mission plan I used: image

junwoo091400 avatar Aug 12 '22 17:08 junwoo091400

How does this work on a fw vehicle? Would it still rtl and takeoff? That could be dangerous.

ryanjAA avatar Aug 13 '22 02:08 ryanjAA

Where does this sit with https://github.com/PX4/PX4-Autopilot/pull/20172? Still wanted?

dagar avatar Sep 15 '22 23:09 dagar

There was a discussion that this is dangerous in general from @MaEtUgR as well if I recall correctly. However, currently 'Waypoint' mission item when vehicle is landed will result in vehicle taking off.

I think it's a bit weird to just restrict RTL when the waypoint item works. Any thoughts on this? For Fixed-wing I agree that this shouldn't be the case.

junwoo091400 avatar Sep 23 '22 13:09 junwoo091400