diff --git a/ArduCopter/APM_Config.h b/ArduCopter/APM_Config.h index 5b86ade1f5..7f1ecabb7f 100644 --- a/ArduCopter/APM_Config.h +++ b/ArduCopter/APM_Config.h @@ -27,7 +27,7 @@ // features below are disabled by default on all boards //#define CAL_ALWAYS_REBOOT // flight controller will reboot after compass or accelerometer calibration completes //#define DISALLOW_GCS_MODE_CHANGE_DURING_RC_FAILSAFE // disable mode changes from GCS during Radio failsafes. Avoids a race condition for vehicle like Solo in which the RC and telemetry travel along the same link -//#define ADVANCED_FAILSAFE 1 // enabled advanced failsafe which allows running a portion of the mission in failsafe events +//#define AP_COPTER_ADVANCED_FAILSAFE_ENABLED 1 // enabled advanced failsafe which allows running a portion of the mission in failsafe events // other settings //#define THROTTLE_IN_DEADBAND 100 // redefine size of throttle deadband in pwm (0 ~ 1000) diff --git a/ArduCopter/Copter.cpp b/ArduCopter/Copter.cpp index 675b3b07ea..417468160c 100644 --- a/ArduCopter/Copter.cpp +++ b/ArduCopter/Copter.cpp @@ -232,7 +232,7 @@ const AP_Scheduler::Task Copter::scheduler_tasks[] = { #if HAL_ADSB_ENABLED SCHED_TASK(avoidance_adsb_update, 10, 100, 138), #endif -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED SCHED_TASK(afs_fs_check, 10, 100, 141), #endif #if AP_TERRAIN_AVAILABLE diff --git a/ArduCopter/Copter.h b/ArduCopter/Copter.h index 60c0818e63..48b6141c9a 100644 --- a/ArduCopter/Copter.h +++ b/ArduCopter/Copter.h @@ -137,7 +137,7 @@ #include #endif -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED # include "afs_copter.h" #endif #if TOY_MODE_ENABLED @@ -183,7 +183,7 @@ public: friend class ParametersG2; friend class AP_Avoidance_Copter; -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED friend class AP_AdvancedFailsafe_Copter; #endif friend class AP_Arming_Copter; @@ -804,7 +804,7 @@ private: // failsafe.cpp void failsafe_enable(); void failsafe_disable(); -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED void afs_fs_check(void); #endif diff --git a/ArduCopter/GCS_Mavlink.cpp b/ArduCopter/GCS_Mavlink.cpp index 1e4e6da598..6c2d169db8 100644 --- a/ArduCopter/GCS_Mavlink.cpp +++ b/ArduCopter/GCS_Mavlink.cpp @@ -1519,7 +1519,7 @@ void GCS_MAVLINK_Copter::handle_message(const mavlink_message_t &msg) } MAV_RESULT GCS_MAVLINK_Copter::handle_flight_termination(const mavlink_command_int_t &packet) { -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED if (GCS_MAVLINK::handle_flight_termination(packet) == MAV_RESULT_ACCEPTED) { return MAV_RESULT_ACCEPTED; } diff --git a/ArduCopter/Parameters.cpp b/ArduCopter/Parameters.cpp index 8f54254821..ef7f785bea 100644 --- a/ArduCopter/Parameters.cpp +++ b/ArduCopter/Parameters.cpp @@ -771,7 +771,7 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { // @User: Advanced AP_GROUPINFO("GND_EFFECT_COMP", 5, ParametersG2, gndeffect_comp_enabled, 1), -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED // @Group: AFS_ // @Path: ../libraries/AP_AdvancedFailsafe/AP_AdvancedFailsafe.cpp AP_SUBGROUPINFO(afs, "AFS_", 6, ParametersG2, AP_AdvancedFailsafe), @@ -1251,7 +1251,7 @@ ParametersG2::ParametersG2(void) #if HAL_PROXIMITY_ENABLED , proximity() #endif -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED ,afs() #endif #if MODE_SMARTRTL_ENABLED diff --git a/ArduCopter/Parameters.h b/ArduCopter/Parameters.h index 0eee405833..7ba292bc5f 100644 --- a/ArduCopter/Parameters.h +++ b/ArduCopter/Parameters.h @@ -530,8 +530,8 @@ public: // whether to enforce acceptance of packets only from sysid_my_gcs AP_Int8 sysid_enforce; - -#if ADVANCED_FAILSAFE + +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED // advanced failsafe library AP_AdvancedFailsafe_Copter afs; #endif diff --git a/ArduCopter/afs_copter.cpp b/ArduCopter/afs_copter.cpp index a0b83b36ca..0d639e1276 100644 --- a/ArduCopter/afs_copter.cpp +++ b/ArduCopter/afs_copter.cpp @@ -4,7 +4,7 @@ #include "Copter.h" -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED /* setup radio_out values for all channels to termination values @@ -63,4 +63,4 @@ AP_AdvancedFailsafe::control_mode AP_AdvancedFailsafe_Copter::afs_mode(void) { copter.set_mode(Mode::Number::AUTO,ModeReason::GCS_FAILSAFE); } -#endif // ADVANCED_FAILSAFE +#endif // AP_COPTER_ADVANCED_FAILSAFE_ENABLED diff --git a/ArduCopter/afs_copter.h b/ArduCopter/afs_copter.h index 29e2dfa7a3..4d133f6276 100644 --- a/ArduCopter/afs_copter.h +++ b/ArduCopter/afs_copter.h @@ -18,7 +18,9 @@ advanced failsafe support for copter */ -#if ADVANCED_FAILSAFE +#include "config.h" + +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED #include /* @@ -44,5 +46,5 @@ protected: void set_mode_auto(void) override; }; -#endif // ADVANCED_FAILSAFE +#endif // AP_COPTER_ADVANCED_FAILSAFE_ENABLED diff --git a/ArduCopter/config.h b/ArduCopter/config.h index 3faf4609c6..0da560ea09 100644 --- a/ArduCopter/config.h +++ b/ArduCopter/config.h @@ -574,8 +574,8 @@ // Developer Items // -#ifndef ADVANCED_FAILSAFE -# define ADVANCED_FAILSAFE 0 +#ifndef AP_COPTER_ADVANCED_FAILSAFE_ENABLED +# define AP_COPTER_ADVANCED_FAILSAFE_ENABLED 0 #endif #ifndef CH_MODE_DEFAULT diff --git a/ArduCopter/events.cpp b/ArduCopter/events.cpp index d49ce3d01a..3002e773c0 100644 --- a/ArduCopter/events.cpp +++ b/ArduCopter/events.cpp @@ -492,7 +492,7 @@ void Copter::do_failsafe_action(FailsafeAction action, ModeReason reason){ set_mode_SmartRTL_or_land_with_pause(reason); break; case FailsafeAction::TERMINATE: { -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED g2.afs.gcs_terminate(true, "Failsafe"); #else arming.disarm(AP_Arming::Method::FAILSAFE_ACTION_TERMINATE); diff --git a/ArduCopter/failsafe.cpp b/ArduCopter/failsafe.cpp index 57864b01be..f143505977 100644 --- a/ArduCopter/failsafe.cpp +++ b/ArduCopter/failsafe.cpp @@ -72,7 +72,7 @@ void Copter::failsafe_check() } -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED /* check for AFS failsafe check */ diff --git a/ArduCopter/mode.h b/ArduCopter/mode.h index faf22b0180..5579b51fb7 100644 --- a/ArduCopter/mode.h +++ b/ArduCopter/mode.h @@ -4,7 +4,7 @@ #include #include // TODO why is this needed if Copter.h includes this -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED #include "afs_copter.h" #endif @@ -134,7 +134,7 @@ public: virtual bool allows_flip() const { return false; } virtual bool crash_check_enabled() const { return true; } -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED // Return the type of this mode for use by advanced failsafe virtual AP_AdvancedFailsafe_Copter::control_mode afs_mode() const { return AP_AdvancedFailsafe_Copter::control_mode::AFS_STABILIZED; } #endif @@ -517,7 +517,7 @@ public: bool allows_inverted() const override { return true; }; #endif -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED // Return the type of this mode for use by advanced failsafe AP_AdvancedFailsafe_Copter::control_mode afs_mode() const override { return AP_AdvancedFailsafe_Copter::control_mode::AFS_AUTO; } #endif @@ -1068,7 +1068,7 @@ public: bool requires_terrain_failsafe() const override { return true; } -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED // Return the type of this mode for use by advanced failsafe AP_AdvancedFailsafe_Copter::control_mode afs_mode() const override { return AP_AdvancedFailsafe_Copter::control_mode::AFS_AUTO; } #endif @@ -1243,7 +1243,7 @@ public: bool is_landing() const override { return true; }; -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED // Return the type of this mode for use by advanced failsafe AP_AdvancedFailsafe_Copter::control_mode afs_mode() const override { return AP_AdvancedFailsafe_Copter::control_mode::AFS_AUTO; } #endif @@ -1425,7 +1425,7 @@ public: bool requires_terrain_failsafe() const override { return true; } -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED // Return the type of this mode for use by advanced failsafe AP_AdvancedFailsafe_Copter::control_mode afs_mode() const override { return AP_AdvancedFailsafe_Copter::control_mode::AFS_AUTO; } #endif diff --git a/ArduCopter/motors.cpp b/ArduCopter/motors.cpp index 45eccc3e84..e382cb5941 100644 --- a/ArduCopter/motors.cpp +++ b/ArduCopter/motors.cpp @@ -135,7 +135,7 @@ void Copter::auto_disarm_check() // motors_output - send output to motors library which will adjust and send to ESCs and servos void Copter::motors_output() { -#if ADVANCED_FAILSAFE +#if AP_COPTER_ADVANCED_FAILSAFE_ENABLED // this is to allow the failsafe module to deliberately crash // the vehicle. Only used in extreme circumstances to meet the // OBC rules