From be93d8212cb0aba0d8e6afa4cb68415c2f17adaf Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 20 Sep 2022 17:37:48 +1000 Subject: [PATCH] ArduCopter: add AP_GRIPPER_ENABLED --- ArduCopter/APM_Config.h | 1 - ArduCopter/Copter.cpp | 2 +- ArduCopter/Copter.h | 3 ++- ArduCopter/Parameters.cpp | 2 +- ArduCopter/Parameters.h | 5 +++-- ArduCopter/config.h | 6 ------ ArduCopter/crash_check.cpp | 2 +- ArduCopter/events.cpp | 2 +- ArduCopter/mode_auto.cpp | 4 ++-- ArduCopter/system.cpp | 2 +- 10 files changed, 12 insertions(+), 17 deletions(-) diff --git a/ArduCopter/APM_Config.h b/ArduCopter/APM_Config.h index ba11728901..58ba9a5c5b 100644 --- a/ArduCopter/APM_Config.h +++ b/ArduCopter/APM_Config.h @@ -13,7 +13,6 @@ //#define BEACON_ENABLED DISABLED // disable beacon support //#define SPRAYER_ENABLED DISABLED // disable the crop sprayer feature (two ESC controlled pumps the speed of which depends upon the vehicle's horizontal velocity) //#define WINCH_ENABLED DISABLED // disable winch support -//#define GRIPPER_ENABLED DISABLED // disable gripper support //#define STATS_ENABLED DISABLED // disable statistics support //#define MODE_ACRO_ENABLED DISABLED // disable acrobatic mode support //#define MODE_AUTO_ENABLED DISABLED // disable auto mode support diff --git a/ArduCopter/Copter.cpp b/ArduCopter/Copter.cpp index cb615b74e8..68f22382dd 100644 --- a/ArduCopter/Copter.cpp +++ b/ArduCopter/Copter.cpp @@ -227,7 +227,7 @@ const AP_Scheduler::Task Copter::scheduler_tasks[] = { #if AP_TERRAIN_AVAILABLE SCHED_TASK(terrain_update, 10, 100, 144), #endif -#if GRIPPER_ENABLED == ENABLED +#if AP_GRIPPER_ENABLED SCHED_TASK_CLASS(AP_Gripper, &copter.g2.gripper, update, 10, 75, 147), #endif #if WINCH_ENABLED == ENABLED diff --git a/ArduCopter/Copter.h b/ArduCopter/Copter.h index 6537111e1f..fc1aa937aa 100644 --- a/ArduCopter/Copter.h +++ b/ArduCopter/Copter.h @@ -109,7 +109,8 @@ #include #include #endif -#if GRIPPER_ENABLED == ENABLED +#include +#if AP_GRIPPER_ENABLED # include #endif #if PRECISION_LANDING == ENABLED diff --git a/ArduCopter/Parameters.cpp b/ArduCopter/Parameters.cpp index aec64e37ad..ed6004aa25 100644 --- a/ArduCopter/Parameters.cpp +++ b/ArduCopter/Parameters.cpp @@ -825,7 +825,7 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { AP_SUBGROUPINFO(stats, "STAT", 12, ParametersG2, AP_Stats), #endif -#if GRIPPER_ENABLED == ENABLED +#if AP_GRIPPER_ENABLED // @Group: GRIP_ // @Path: ../libraries/AP_Gripper/AP_Gripper.cpp AP_SUBGROUPINFO(gripper, "GRIP_", 13, ParametersG2, AP_Gripper), diff --git a/ArduCopter/Parameters.h b/ArduCopter/Parameters.h index 2f7221cec5..1c4e3f03ad 100644 --- a/ArduCopter/Parameters.h +++ b/ArduCopter/Parameters.h @@ -4,7 +4,8 @@ #include "RC_Channel.h" #include -#if GRIPPER_ENABLED == ENABLED +#include +#if AP_GRIPPER_ENABLED # include #endif #if MODE_FOLLOW_ENABLED == ENABLED @@ -502,7 +503,7 @@ public: AP_Stats stats; #endif -#if GRIPPER_ENABLED +#if AP_GRIPPER_ENABLED AP_Gripper gripper; #endif diff --git a/ArduCopter/config.h b/ArduCopter/config.h index 70dee779fb..fc074d4014 100644 --- a/ArduCopter/config.h +++ b/ArduCopter/config.h @@ -181,12 +181,6 @@ # define PRECISION_LANDING ENABLED #endif -////////////////////////////////////////////////////////////////////////////// -// gripper - enabled only on larger firmwares -#ifndef GRIPPER_ENABLED - # define GRIPPER_ENABLED !HAL_MINIMIZE_FEATURES -#endif - ////////////////////////////////////////////////////////////////////////////// // winch support #ifndef WINCH_ENABLED diff --git a/ArduCopter/crash_check.cpp b/ArduCopter/crash_check.cpp index b57114ae7c..2b2c0e5a12 100644 --- a/ArduCopter/crash_check.cpp +++ b/ArduCopter/crash_check.cpp @@ -170,7 +170,7 @@ void Copter::thrust_loss_check() motors->set_thrust_boost(true); // the motors library disables this when it is no longer needed to achieve the commanded output -#if GRIPPER_ENABLED == ENABLED +#if AP_GRIPPER_ENABLED if ((copter.g2.flight_options & uint32_t(FlightOptions::RELEASE_GRIPPER_ON_THRUST_LOSS)) != 0) { copter.g2.gripper.release(); } diff --git a/ArduCopter/events.cpp b/ArduCopter/events.cpp index 6d9a6f72df..6d7e8f563c 100644 --- a/ArduCopter/events.cpp +++ b/ArduCopter/events.cpp @@ -478,7 +478,7 @@ void Copter::do_failsafe_action(FailsafeAction action, ModeReason reason){ break; } -#if GRIPPER_ENABLED == ENABLED +#if AP_GRIPPER_ENABLED if (failsafe_option(FailsafeOption::RELEASE_GRIPPER)) { copter.g2.gripper.release(); } diff --git a/ArduCopter/mode_auto.cpp b/ArduCopter/mode_auto.cpp index 1ff806139f..3ae434f59a 100644 --- a/ArduCopter/mode_auto.cpp +++ b/ArduCopter/mode_auto.cpp @@ -1978,7 +1978,7 @@ bool ModeAuto::verify_payload_place() case PayloadPlaceStateType_Releasing_Start: // Reinitialise vertical position controller to remove discontinuity due to touch down of payload pos_control->init_z_controller_no_descent(); -#if GRIPPER_ENABLED == ENABLED +#if AP_GRIPPER_ENABLED if (g2.gripper.valid()) { gcs().send_text(MAV_SEVERITY_INFO, "PayloadPlace: Releasing the gripper"); g2.gripper.release(); @@ -1995,7 +1995,7 @@ bool ModeAuto::verify_payload_place() nav_payload_place.state = PayloadPlaceStateType_Releasing; FALLTHROUGH; case PayloadPlaceStateType_Releasing: -#if GRIPPER_ENABLED == ENABLED +#if AP_GRIPPER_ENABLED if (g2.gripper.valid() && !g2.gripper.released()) { return false; } diff --git a/ArduCopter/system.cpp b/ArduCopter/system.cpp index ed7aae0551..918160dad4 100644 --- a/ArduCopter/system.cpp +++ b/ArduCopter/system.cpp @@ -27,7 +27,7 @@ void Copter::init_ardupilot() #endif // init cargo gripper -#if GRIPPER_ENABLED == ENABLED +#if AP_GRIPPER_ENABLED g2.gripper.init(); #endif