@@ -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
0 commit comments