Copter: Standby functions

This commit is contained in:
Leonard Hall 2019-09-28 23:07:57 +09:30 committed by Randy Mackay
parent 3274398bc2
commit 50a098c359
6 changed files with 64 additions and 0 deletions

View File

@ -144,6 +144,7 @@ const AP_Scheduler::Task Copter::scheduler_tasks[] = {
SCHED_TASK(ekf_check, 10, 75), SCHED_TASK(ekf_check, 10, 75),
SCHED_TASK(gpsglitch_check, 10, 50), SCHED_TASK(gpsglitch_check, 10, 50),
SCHED_TASK(landinggear_update, 10, 75), SCHED_TASK(landinggear_update, 10, 75),
SCHED_TASK(standby_update, 100, 75),
SCHED_TASK(lost_vehicle_check, 10, 50), SCHED_TASK(lost_vehicle_check, 10, 50),
SCHED_TASK_CLASS(GCS, (GCS*)&copter._gcs, update_receive, 400, 180), SCHED_TASK_CLASS(GCS, (GCS*)&copter._gcs, update_receive, 400, 180),
SCHED_TASK_CLASS(GCS, (GCS*)&copter._gcs, update_send, 400, 550), SCHED_TASK_CLASS(GCS, (GCS*)&copter._gcs, update_send, 400, 550),

View File

@ -582,6 +582,8 @@ private:
float takeoff_alt_cm; float takeoff_alt_cm;
} gndeffect_state; } gndeffect_state;
bool standby_active;
// set when we are upgrading parameters from 3.4 // set when we are upgrading parameters from 3.4
bool upgrading_frame_params; bool upgrading_frame_params;
@ -744,6 +746,9 @@ private:
// landing_gear.cpp // landing_gear.cpp
void landinggear_update(); void landinggear_update();
// standby.cpp
void standby_update();
// Log.cpp // Log.cpp
void Log_Write_Control_Tuning(); void Log_Write_Control_Tuning();
void Log_Write_Performance(); void Log_Write_Performance();

View File

@ -77,6 +77,7 @@ void RC_Channel_Copter::init_aux_function(const aux_func_t ch_option, const aux_
case AUX_FUNC::PRECISION_LOITER: case AUX_FUNC::PRECISION_LOITER:
case AUX_FUNC::INVERTED: case AUX_FUNC::INVERTED:
case AUX_FUNC::WINCH_ENABLE: case AUX_FUNC::WINCH_ENABLE:
case AUX_FUNC::STAND_BY:
case AUX_FUNC::SURFACE_TRACKING: case AUX_FUNC::SURFACE_TRACKING:
do_aux_function(ch_option, ch_flag); do_aux_function(ch_option, ch_flag);
break; break;
@ -542,6 +543,22 @@ void RC_Channel_Copter::do_aux_function(const aux_func_t ch_option, const aux_sw
#endif #endif
break; break;
case AUX_FUNC::STAND_BY: {
switch (ch_flag) {
case HIGH:
copter.standby_active = true;
copter.Log_Write_Event(DATA_STAND_BY_ENABLE);
gcs().send_text(MAV_SEVERITY_INFO, "Stand By Enabled");
break;
default:
copter.standby_active = false;
copter.Log_Write_Event(DATA_STAND_BY_DISABLE);
gcs().send_text(MAV_SEVERITY_INFO, "Stand By Disabled");
break;
}
break;
}
case AUX_FUNC::SURFACE_TRACKING: case AUX_FUNC::SURFACE_TRACKING:
switch (ch_flag) { switch (ch_flag) {
case LOW: case LOW:

View File

@ -23,6 +23,12 @@ void Copter::crash_check()
return; return;
} }
// exit immediately if in standby
if (standby_active) {
crash_counter = 0;
return;
}
// return immediately if we are not in an angle stabilize flight mode or we are flipping // return immediately if we are not in an angle stabilize flight mode or we are flipping
if (control_mode == Mode::Number::ACRO || control_mode == Mode::Number::FLIP) { if (control_mode == Mode::Number::ACRO || control_mode == Mode::Number::FLIP) {
crash_counter = 0; crash_counter = 0;
@ -73,6 +79,11 @@ void Copter::thrust_loss_check()
return; return;
} }
// exit immediately if in standby
if (standby_active) {
return;
}
// check for desired angle over 15 degrees // check for desired angle over 15 degrees
// todo: add thrust angle to AC_AttitudeControl // todo: add thrust angle to AC_AttitudeControl
const Vector3f angle_target = attitude_control->get_att_target_euler_cd(); const Vector3f angle_target = attitude_control->get_att_target_euler_cd();
@ -142,6 +153,11 @@ void Copter::parachute_check()
return; return;
} }
// exit immediately if in standby
if (standby_active) {
return;
}
// call update to give parachute a chance to move servo or relay back to off position // call update to give parachute a chance to move servo or relay back to off position
parachute.update(); parachute.update();

View File

@ -54,6 +54,9 @@ void Copter::update_land_detector()
#endif #endif
set_land_complete(false); set_land_complete(false);
} }
} else if (standby_active) {
// land detector will not run in standby mode
land_detector_count = 0;
} else { } else {
#if FRAME_CONFIG == HELI_FRAME #if FRAME_CONFIG == HELI_FRAME

22
ArduCopter/standby.cpp Normal file
View File

@ -0,0 +1,22 @@
#include "Copter.h"
// Run standby functions at approximately 100 Hz to limit maximum variable build up
//
// When standby is active:
// all I terms are continually reset
// heading error is reset to zero
// position errors are reset to zero
// crash_check is disabled
// thrust_loss_check is disabled
// parachute_check is disabled
// and landing detection is disabled.
void Copter::standby_update()
{
if (!standby_active) {
return;
}
attitude_control->reset_rate_controller_I_terms();
attitude_control->set_yaw_target_to_current_heading();
pos_control->standby_xyz_reset();
}