Skip to content

Commit 8a17d8c

Browse files
committed
FixedWingLandDetector: force to landed during runway takeoff
1 parent 9dae14a commit 8a17d8c

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/modules/land_detector/FixedwingLandDetector.cpp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,31 @@ bool FixedwingLandDetector::_get_landed_state()
5757
return true;
5858
}
5959

60-
bool landDetected = false;
60+
// Force the landed state to stay landed if we're currently in an early state of the takeoff state machines.
61+
// This prevents premature transitions to in-air during the early takeoff phase.
62+
if (_landed_hysteresis.get_state()) {
63+
launch_detection_status_s launch_detection_status{};
64+
_launch_detection_status_sub.copy(&launch_detection_status);
6165

62-
launch_detection_status_s launch_detection_status{};
63-
_launch_detection_status_sub.copy(&launch_detection_status);
66+
fixed_wing_runway_control_s fixed_wing_runway_control{};
67+
_fixed_wing_runway_control_sub.copy(&fixed_wing_runway_control);
6468

65-
// force the landed state to stay landed if we're currently in the catapult/hand-launch launch process. Detect that we are in this state
66-
// by checking if the last publication of launch_detection_status is less than 0.5s old, and we're still in the wait for launch state.
67-
if (_landed_hysteresis.get_state() && hrt_elapsed_time(&launch_detection_status.timestamp) < 500_ms
68-
&& launch_detection_status.launch_detection_state == launch_detection_status_s::STATE_WAITING_FOR_LAUNCH) {
69-
landDetected = true;
69+
// Check if we're in catapult/hand-launch waiting state
70+
const bool waiting_for_catapult_launch = hrt_elapsed_time(&launch_detection_status.timestamp) < 500_ms
71+
&& launch_detection_status.launch_detection_state == launch_detection_status_s::STATE_WAITING_FOR_LAUNCH;
72+
73+
// Check if we're in runway takeoff early phase (throttle ramp or clamped to runway)
74+
const bool waiting_for_auto_runway_climbout = hrt_elapsed_time(&fixed_wing_runway_control.timestamp) < 500_ms
75+
&& fixed_wing_runway_control.runway_takeoff_state < fixed_wing_runway_control_s::STATE_CLIMBOUT;
76+
77+
if (waiting_for_catapult_launch || waiting_for_auto_runway_climbout) {
78+
return true;
79+
}
80+
}
81+
82+
bool landDetected = false;
7083

71-
} else if (hrt_elapsed_time(&_vehicle_local_position.timestamp) < 1_s) {
84+
if (hrt_elapsed_time(&_vehicle_local_position.timestamp) < 1_s) {
7285

7386
float val = 0.0f;
7487

src/modules/land_detector/FixedwingLandDetector.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
#include <matrix/math.hpp>
4646
#include <uORB/topics/airspeed_validated.h>
47+
#include <uORB/topics/fixed_wing_runway_control.h>
4748
#include <uORB/topics/launch_detection_status.h>
4849

4950
#include "LandDetector.h"
@@ -67,6 +68,7 @@ class FixedwingLandDetector final : public LandDetector
6768
private:
6869
uORB::Subscription _airspeed_validated_sub{ORB_ID(airspeed_validated)};
6970
uORB::Subscription _launch_detection_status_sub{ORB_ID(launch_detection_status)};
71+
uORB::Subscription _fixed_wing_runway_control_sub{ORB_ID(fixed_wing_runway_control)};
7072

7173
float _airspeed_filtered{0.0f};
7274
float _velocity_xy_filtered{0.0f};

0 commit comments

Comments
 (0)