mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-05 18:20:40 +08:00
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:
committed by
Beat Küng
parent
a2299b02c8
commit
d97a8d7d3b
@@ -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) {
|
||||
|
||||
@@ -563,6 +563,10 @@ void ModeManagement::updateActiveConfigOverrides(uint8_t nav_state, config_overr
|
||||
current_overrides.disable_auto_disarm = true;
|
||||
}
|
||||
|
||||
if (executor_overrides.disable_auto_set_home) {
|
||||
current_overrides.disable_auto_set_home = true;
|
||||
}
|
||||
|
||||
if (executor_overrides.defer_failsafes) {
|
||||
current_overrides.defer_failsafes = true;
|
||||
current_overrides.defer_failsafes_timeout_s = executor_overrides.defer_failsafes_timeout_s;
|
||||
|
||||
Reference in New Issue
Block a user