Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plane: fixed TECS state reset in VTOL auto #24191

Merged
merged 1 commit into from Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions ArduPlane/ArduPlane.cpp
Expand Up @@ -204,7 +204,13 @@ void Plane::ahrs_update()
*/
void Plane::update_speed_height(void)
{
if (control_mode->does_auto_throttle()) {
bool should_run_tecs = control_mode->does_auto_throttle();
#if HAL_QUADPLANE_ENABLED
if (quadplane.should_disable_TECS()) {
should_run_tecs = false;
}
#endif
if (should_run_tecs) {
// Call TECS 50Hz update. Note that we call this regardless of
// throttle suppressed, as this needs to be running for
// takeoff detection
Expand Down Expand Up @@ -538,7 +544,14 @@ void Plane::update_alt()
}
#endif

if (control_mode->does_auto_throttle() && !throttle_suppressed) {
bool should_run_tecs = control_mode->does_auto_throttle();
#if HAL_QUADPLANE_ENABLED
if (quadplane.should_disable_TECS()) {
should_run_tecs = false;
}
#endif

if (should_run_tecs && !throttle_suppressed) {

float distance_beyond_land_wp = 0;
if (flight_stage == AP_FixedWing::FlightStage::LAND &&
Expand Down
16 changes: 16 additions & 0 deletions ArduPlane/quadplane.cpp
Expand Up @@ -4560,4 +4560,20 @@ bool QuadPlane::allow_stick_mixing() const
return transition->allow_stick_mixing();
}

/*
return true if we should disable TECS in the current flight state
this ensures that TECS resets when we change height in a VTOL mode
*/
bool QuadPlane::should_disable_TECS() const
{
if (in_vtol_land_descent()) {
return true;
}
if (plane.control_mode == &plane.mode_guided &&
plane.auto_state.vtol_loiter) {
return true;
}
return false;
}

#endif // HAL_QUADPLANE_ENABLED
6 changes: 6 additions & 0 deletions ArduPlane/quadplane.h
Expand Up @@ -184,6 +184,12 @@ class QuadPlane
// Should we allow stick mixing from the pilot
bool allow_stick_mixing() const;

/*
should we disable the TECS controller?
only called when in an auto-throttle mode
*/
bool should_disable_TECS() const;

private:
AP_AHRS &ahrs;

Expand Down