mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-16 14:57:35 +08:00
MulticopterPositionControl: reset task when switching mode
to make sure the state is clean between auto mode switches.
This commit is contained in:
committed by
Daniel Agar
parent
85f3ab1960
commit
8f40558f41
@@ -477,6 +477,11 @@ void MulticopterPositionControl::start_flight_task()
|
||||
return;
|
||||
}
|
||||
|
||||
// Switch to clean new task when mode switches e.g. to reset state when switching between auto modes
|
||||
if (_last_vehicle_nav_state != _vehicle_status.nav_state) {
|
||||
_flight_tasks.switchTask(FlightTaskIndex::None);
|
||||
}
|
||||
|
||||
if (_vehicle_status.in_transition_mode) {
|
||||
should_disable_task = false;
|
||||
FlightTaskError error = _flight_tasks.switchTask(FlightTaskIndex::Transition);
|
||||
@@ -666,6 +671,8 @@ void MulticopterPositionControl::start_flight_task()
|
||||
} else if (should_disable_task) {
|
||||
_flight_tasks.switchTask(FlightTaskIndex::None);
|
||||
}
|
||||
|
||||
_last_vehicle_nav_state = _vehicle_status.nav_state;
|
||||
}
|
||||
|
||||
void MulticopterPositionControl::failsafe(const hrt_abstime &now, vehicle_local_position_setpoint_s &setpoint,
|
||||
|
||||
@@ -203,6 +203,8 @@ private:
|
||||
|
||||
perf_counter_t _cycle_perf;
|
||||
|
||||
uint8_t _last_vehicle_nav_state{0};
|
||||
|
||||
/**
|
||||
* Update our local parameter cache.
|
||||
* Parameter update can be forced when argument is true.
|
||||
|
||||
Reference in New Issue
Block a user