mode: control auto set home from an external mode

The mode executor can run land mode which updates the home position to the landing location. This
can be not the desirable behavior and the home position should stay at the original location.

A flag is added to the configuration overrides to control if the home position is updated or not.
This commit is contained in:
Michael Schaeuble authored and Beat Küng committed 2025-11-26 10:16:54 +01:00
1 parent a2299b02c8
commit d97a8d7d3b
6 files changed
+73 -5

No files matched your search

+4 -3
View File
@@ -638,7 +638,7 @@ transition_result_t Commander::arm(arm_disarm_reason_t calling_reason, bool run_
events::send<events::px4::enums::arm_disarm_reason_t>(events::ID("commander_armed_by"), events::Log::Info,
"Armed by {1}", calling_reason);
if (_param_com_home_en.get() && !_mission_in_progress) {
if (_param_com_home_en.get() && !_mission_in_progress && !_config_overrides.disable_auto_set_home) {
_home_position.setHomePosition();
}
@@ -1850,7 +1850,8 @@ void Commander::run()
_mission_in_progress = (_vehicle_status.nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION)
&& !_mission_result_sub.get().finished;
_home_position.update(_param_com_home_en.get(), !isArmed() && _vehicle_land_detected.landed && !_mission_in_progress);
_home_position.update(_param_com_home_en.get(), !isArmed() && _vehicle_land_detected.landed && !_mission_in_progress
&& !_config_overrides.disable_auto_set_home);
handleAutoDisarm();
@@ -2140,7 +2141,7 @@ void Commander::landDetectorUpdate()
}
// automatically set or update home position
if (_param_com_home_en.get() && !_mission_in_progress) {
if (_param_com_home_en.get() && !_mission_in_progress && !_config_overrides.disable_auto_set_home) {
// set the home position when taking off
if (!_vehicle_land_detected.landed) {
if (was_landed) {