feat(Commander): add COM_FLTMODE_BOOT parameter for configurable flight mode on boot (#27641)

* feat(Commander): add COM_FLTMODE_BOOT parameter for configurable flight mode on boot

This adds COM_FLTMODE_BOOT, an enum parameter (Altitude/Position/Hold/Stabilized, default Hold) that controls the nav_state set on boot, before any user mode command is received.

The navStateFromParam() translation function (previously a ManualControl method) has been moved to mode_util::navStateFromFlightModeParam() in ModeUtil/conversions.hpp so COM_FLTMODE_BOOT can follow the same enumeration as COM_FLTMODE* params.

* chore(commander): use nav_state for mode mapping

* feat(commander): extend list of modes available

* chore: fix style

* refactor(commander): simplify COM_FLTMODE_BOOT boot mode initialization

Apply the configured boot flight mode directly in the Commander
constructor.

Also removes the stick-presence-based mode logic (everHadModeChange
check in manualControlCheck), and changes the default to Position (NAVIGATION_STATE_POSCTL).

* chore: remove accidental whitespace

* chore: set default COM_FLTMODE_BOOT to Hold (nav_state 4)

* feat: add Takeoff state to COM_FLTMODE_BOOT
This commit is contained in:
Mahima Yoga
2026-06-18 18:37:23 +02:00
committed by GitHub
parent e9e13a4537
commit 45cd19bcff
5 changed files with 34 additions and 17 deletions

View File

@@ -837,6 +837,9 @@ Commander::Commander() :
updateParameters();
// Apply the configured boot flight mode before the first run
_user_mode_intention.change((uint8_t)_param_com_fltmode_boot.get(), ModeChangeSource::User, false, true);
_failsafe.setOnNotifyUserCallback(&Commander::onFailsafeNotifyUserTrampoline, this);
_auto_disarm_killed.set_hysteresis_time_from(false, 5_s);
}
@@ -3153,13 +3156,6 @@ void Commander::manualControlCheck()
}
}
} else {
const bool is_mavlink = (manual_control_setpoint.data_source > manual_control_setpoint_s::SOURCE_RC);
// if there's never been a mode change force position control as initial state
if (!_user_mode_intention.everHadModeChange() && (is_mavlink || !_mode_switch_mapped)) {
_user_mode_intention.change(vehicle_status_s::NAVIGATION_STATE_POSCTL, ModeChangeSource::User, false, true);
}
}
}
}