From ccc9231c6705093a22e17eda1d35598d18916c2e Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 21 Feb 2024 17:40:36 +1100 Subject: [PATCH] ArduSub: move gripper up to AP_Vehicle also make the singleton return a reference rather than a pointer --- ArduSub/ArduSub.cpp | 3 --- ArduSub/Parameters.cpp | 23 ++++++++++++++++++----- ArduSub/Parameters.h | 5 ----- ArduSub/Sub.h | 5 ----- ArduSub/system.cpp | 5 ----- 5 files changed, 18 insertions(+), 23 deletions(-) diff --git a/ArduSub/ArduSub.cpp b/ArduSub/ArduSub.cpp index f75ff5f9dc..2306c31b8d 100644 --- a/ArduSub/ArduSub.cpp +++ b/ArduSub/ArduSub.cpp @@ -102,9 +102,6 @@ const AP_Scheduler::Task Sub::scheduler_tasks[] = { SCHED_TASK_CLASS(AP_RPM, &sub.rpm_sensor, update, 10, 200, 66), #endif SCHED_TASK(terrain_update, 10, 100, 72), -#if AP_GRIPPER_ENABLED - SCHED_TASK_CLASS(AP_Gripper, &sub.g2.gripper, update, 10, 75, 75), -#endif #if AP_STATS_ENABLED SCHED_TASK(stats_update, 1, 200, 76), #endif diff --git a/ArduSub/Parameters.cpp b/ArduSub/Parameters.cpp index 58e554f348..8d0fd2ef97 100644 --- a/ArduSub/Parameters.cpp +++ b/ArduSub/Parameters.cpp @@ -1,5 +1,7 @@ #include "Sub.h" +#include + /* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -693,11 +695,7 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { AP_SUBGROUPINFO(proximity, "PRX", 2, ParametersG2, AP_Proximity), #endif -#if AP_GRIPPER_ENABLED - // @Group: GRIP_ - // @Path: ../libraries/AP_Gripper/AP_Gripper.cpp - AP_SUBGROUPINFO(gripper, "GRIP_", 3, ParametersG2, AP_Gripper), -#endif + // 3 was AP_Gripper // @Group: SERVO // @Path: ../libraries/SRV_Channel/SRV_Channels.cpp @@ -791,6 +789,21 @@ void Sub::load_parameters() } #endif + // PARAMETER_CONVERSION - Added: Feb-2024 +#if AP_GRIPPER_ENABLED + { + // Find G2's Top Level Key + AP_Param::ConversionInfo gripper_info; + if (!AP_Param::find_top_level_key_by_pointer(&g2, gripper_info.old_key)) { + return; + } + + const uint16_t old_gripper_index = 3; // Old parameter index in g2 + const uint16_t old_gripper_top_element = 4035; // Old group element in the tree for the first subgroup element (see AP_PARAM_KEY_DUMP) + AP_Param::convert_class(gripper_info.old_key, &gripper, gripper.var_info, old_gripper_index, old_gripper_top_element, false); + } +#endif + // PARAMETER_CONVERSION - Added: Feb-2024 #if HAL_LOGGING_ENABLED AP_Param::convert_class(g.k_param_logger, &logger, logger.var_info, 0, 0, true); diff --git a/ArduSub/Parameters.h b/ArduSub/Parameters.h index f8fd851fbf..6ea9608f8c 100644 --- a/ArduSub/Parameters.h +++ b/ArduSub/Parameters.h @@ -4,7 +4,6 @@ #include -#include #include // Global parameter class. @@ -353,10 +352,6 @@ public: // var_info for holding Parameter information static const struct AP_Param::GroupInfo var_info[]; -#if AP_GRIPPER_ENABLED - AP_Gripper gripper; -#endif - #if HAL_PROXIMITY_ENABLED // proximity (aka object avoidance) library AP_Proximity proximity; diff --git a/ArduSub/Sub.h b/ArduSub/Sub.h index 2419e0fc79..69b43eb8a5 100644 --- a/ArduSub/Sub.h +++ b/ArduSub/Sub.h @@ -88,11 +88,6 @@ #include #endif -#include -#if AP_GRIPPER_ENABLED -#include // gripper stuff -#endif - #if AVOIDANCE_ENABLED == ENABLED #include // Stop at fence library #endif diff --git a/ArduSub/system.cpp b/ArduSub/system.cpp index b72b9889c1..54eb0676b2 100644 --- a/ArduSub/system.cpp +++ b/ArduSub/system.cpp @@ -14,11 +14,6 @@ static void failsafe_check_static() void Sub::init_ardupilot() { - // init cargo gripper -#if AP_GRIPPER_ENABLED - g2.gripper.init(); -#endif - // initialise notify system notify.init();