From 700f850b58b4d0516619b2bba2295cb777872c6f Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 30 Jan 2024 15:15:47 +1100 Subject: [PATCH 01/18] ArduCopter: add comment for lost AP_Stats object params --- ArduCopter/Parameters.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ArduCopter/Parameters.cpp b/ArduCopter/Parameters.cpp index e8c2d5039661a3..3da28c69432518 100644 --- a/ArduCopter/Parameters.cpp +++ b/ArduCopter/Parameters.cpp @@ -821,6 +821,8 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { // @User: Advanced AP_GROUPINFO("SYSID_ENFORCE", 11, ParametersG2, sysid_enforce, 0), + // 12 was AP_Stats + #if AP_GRIPPER_ENABLED // @Group: GRIP_ // @Path: ../libraries/AP_Gripper/AP_Gripper.cpp From 9aab59ca9ee5988718e6cfcbe0865f19c9ceea5c Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 30 Jan 2024 15:15:47 +1100 Subject: [PATCH 02/18] ArduPlane: add comment for lost AP_Stats object params --- ArduPlane/Parameters.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ArduPlane/Parameters.cpp b/ArduPlane/Parameters.cpp index 1e6b5901bc8608..113539dd17814b 100644 --- a/ArduPlane/Parameters.cpp +++ b/ArduPlane/Parameters.cpp @@ -1033,6 +1033,8 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { // @User: Advanced AP_GROUPINFO("SYSID_ENFORCE", 4, ParametersG2, sysid_enforce, 0), + // AP_Stats was 5 + // @Group: SERVO // @Path: ../libraries/SRV_Channel/SRV_Channels.cpp AP_SUBGROUPINFO(servo_channels, "SERVO", 6, ParametersG2, SRV_Channels), From 3bf58ad5404fb440dadacdc1ddb0357a2f3acd5e Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 30 Jan 2024 15:15:47 +1100 Subject: [PATCH 03/18] ArduSub: add comment for lost AP_Stats object params --- ArduSub/Parameters.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ArduSub/Parameters.cpp b/ArduSub/Parameters.cpp index 90d493659b4fc3..c87897b83b5cdb 100644 --- a/ArduSub/Parameters.cpp +++ b/ArduSub/Parameters.cpp @@ -690,6 +690,9 @@ const AP_Param::Info Sub::var_info[] = { 2nd group of parameters */ const AP_Param::GroupInfo ParametersG2::var_info[] = { + + // 1 was AP_Stats + #if HAL_PROXIMITY_ENABLED // @Group: PRX // @Path: ../libraries/AP_Proximity/AP_Proximity.cpp From fa0797a5f41a85fb2fbfc226aa767926db6a706c Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 30 Jan 2024 15:15:48 +1100 Subject: [PATCH 04/18] Blimp: add comment for lost AP_Stats object params --- Blimp/Parameters.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Blimp/Parameters.cpp b/Blimp/Parameters.cpp index 592087be62ef25..d231274847d6be 100644 --- a/Blimp/Parameters.cpp +++ b/Blimp/Parameters.cpp @@ -780,6 +780,8 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { // @User: Advanced AP_GROUPINFO("SYSID_ENFORCE", 11, ParametersG2, sysid_enforce, 0), + // 12 was AP_Stats + // @Param: FRAME_CLASS // @DisplayName: Frame Class // @Description: Controls major frame class for blimp. From 13af81ba61a26b60717e1d5a2bb46f5c96ffecc6 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 30 Jan 2024 15:15:48 +1100 Subject: [PATCH 05/18] Rover: add comment for lost AP_Stats object params --- Rover/Parameters.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Rover/Parameters.cpp b/Rover/Parameters.cpp index 66149625735829..3481b7ea49acbf 100644 --- a/Rover/Parameters.cpp +++ b/Rover/Parameters.cpp @@ -404,6 +404,8 @@ const AP_Param::Info Rover::var_info[] = { 2nd group of parameters */ const AP_Param::GroupInfo ParametersG2::var_info[] = { + // 1 was AP_Stats + // @Param: SYSID_ENFORCE // @DisplayName: GCS sysid enforcement // @Description: This controls whether packets from other than the expected GCS system ID will be accepted From 6da7cfcf4e01d5582234b16eea579e5ccb1fa394 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 30 Jan 2024 13:41:27 +1100 Subject: [PATCH 06/18] AP_Vehicle: move scripting up to AP_Vehicle --- libraries/AP_Vehicle/AP_Vehicle.cpp | 15 +++++++++++---- libraries/AP_Vehicle/AP_Vehicle.h | 7 +++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/libraries/AP_Vehicle/AP_Vehicle.cpp b/libraries/AP_Vehicle/AP_Vehicle.cpp index c138c19d79a2a5..fcb78c2799e712 100644 --- a/libraries/AP_Vehicle/AP_Vehicle.cpp +++ b/libraries/AP_Vehicle/AP_Vehicle.cpp @@ -258,6 +258,12 @@ const AP_Param::GroupInfo AP_Vehicle::var_info[] = { AP_SUBGROUPINFO(stats, "STAT", 27, AP_Vehicle, AP_Stats), #endif +#if AP_SCRIPTING_ENABLED + // @Group: SCR_ + // @Path: ../AP_Scripting/AP_Scripting.cpp + AP_SUBGROUPINFO(scripting, "SCR_", 28, AP_Vehicle, AP_Scripting), +#endif + AP_GROUPEND }; @@ -367,6 +373,10 @@ void AP_Vehicle::setup() // init_ardupilot is where the vehicle does most of its initialisation. init_ardupilot(); +#if AP_SCRIPTING_ENABLED + scripting.init(); +#endif // AP_SCRIPTING_ENABLED + #if AP_AIRSPEED_ENABLED airspeed.init(); if (airspeed.enabled()) { @@ -976,10 +986,7 @@ void AP_Vehicle::one_Hz_update(void) } #if AP_SCRIPTING_ENABLED - AP_Scripting *scripting = AP_Scripting::get_singleton(); - if (scripting != nullptr) { - scripting->update(); - } + scripting.update(); #endif } diff --git a/libraries/AP_Vehicle/AP_Vehicle.h b/libraries/AP_Vehicle/AP_Vehicle.h index 32e0f3150cb953..3e38ac9b63691c 100644 --- a/libraries/AP_Vehicle/AP_Vehicle.h +++ b/libraries/AP_Vehicle/AP_Vehicle.h @@ -69,6 +69,9 @@ #include #include #include // statistics library +#if AP_SCRIPTING_ENABLED +#include +#endif class AP_DDS_Client; @@ -415,6 +418,10 @@ class AP_Vehicle : public AP_HAL::HAL::Callbacks { AP_TemperatureSensor temperature_sensor; #endif +#if AP_SCRIPTING_ENABLED + AP_Scripting scripting; +#endif + static const struct AP_Param::GroupInfo var_info[]; static const struct AP_Scheduler::Task scheduler_tasks[]; From 7a14427d2696e6728690ff47839b6b52c9223367 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 30 Jan 2024 13:41:43 +1100 Subject: [PATCH 07/18] Tracker: move scripting up to AP_Vehicle --- AntennaTracker/Parameters.cpp | 11 +++++------ AntennaTracker/Parameters.h | 2 +- AntennaTracker/Tracker.h | 8 -------- AntennaTracker/system.cpp | 4 ---- 4 files changed, 6 insertions(+), 19 deletions(-) diff --git a/AntennaTracker/Parameters.cpp b/AntennaTracker/Parameters.cpp index 20d8da47aa06e9..c21d5dbf4f5d7e 100644 --- a/AntennaTracker/Parameters.cpp +++ b/AntennaTracker/Parameters.cpp @@ -505,12 +505,6 @@ const AP_Param::Info Tracker::var_info[] = { GGROUP(pidYaw2Srv, "YAW2SRV_", AC_PID), -#if AP_SCRIPTING_ENABLED - // @Group: SCR_ - // @Path: ../libraries/AP_Scripting/AP_Scripting.cpp - GOBJECT(scripting, "SCR_", AP_Scripting), -#endif - // @Param: CMD_TOTAL // @DisplayName: Number of loaded mission items // @Description: Set to 1 if HOME location has been loaded by the ground station. Do not change this manually. @@ -619,6 +613,11 @@ void Tracker::load_parameters(void) AP_Param::convert_class(g.k_param_stats_old, &stats, stats.var_info, 0, 0, true); #endif +#if AP_SCRIPTING_ENABLED + // PARAMETER_CONVERSION - Added: Jan-2024 + AP_Param::convert_class(g.k_param_scripting_old, &scripting, scripting.var_info, 0, 0, true); +#endif + hal.console->printf("load_all took %luus\n", (unsigned long)(AP_HAL::micros() - before)); #if HAL_HAVE_SAFETY_SWITCH diff --git a/AntennaTracker/Parameters.h b/AntennaTracker/Parameters.h index 836a70853615e1..1db980b04aaa00 100644 --- a/AntennaTracker/Parameters.h +++ b/AntennaTracker/Parameters.h @@ -115,7 +115,7 @@ class Parameters { k_param_servo_channels, k_param_stats_old = 218, - k_param_scripting = 219, + k_param_scripting_old = 219, // // 220: Waypoint data diff --git a/AntennaTracker/Tracker.h b/AntennaTracker/Tracker.h index 54b2719433fcd2..22c7687ef73ea9 100644 --- a/AntennaTracker/Tracker.h +++ b/AntennaTracker/Tracker.h @@ -53,10 +53,6 @@ #include "AP_Arming.h" -#if AP_SCRIPTING_ENABLED -#include -#endif - #include "mode.h" class Tracker : public AP_Vehicle { @@ -115,10 +111,6 @@ class Tracker : public AP_Vehicle { ModeServoTest mode_servotest; ModeStop mode_stop; -#if AP_SCRIPTING_ENABLED - AP_Scripting scripting; -#endif - // Vehicle state struct { bool location_valid; // true if we have a valid location for the vehicle diff --git a/AntennaTracker/system.cpp b/AntennaTracker/system.cpp index a05be96b61dd24..db4438ded4c063 100644 --- a/AntennaTracker/system.cpp +++ b/AntennaTracker/system.cpp @@ -28,10 +28,6 @@ void Tracker::init_ardupilot() log_init(); #endif -#if AP_SCRIPTING_ENABLED - scripting.init(); -#endif // AP_SCRIPTING_ENABLED - // initialise compass AP::compass().set_log_bit(MASK_LOG_COMPASS); AP::compass().init(); From 33895e88160c5ff5081996eca0125e764b5effc4 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 30 Jan 2024 14:08:53 +1100 Subject: [PATCH 08/18] Plane: move scripting up to AP_Vehicle --- ArduPlane/Parameters.cpp | 20 +++++++++++++++----- ArduPlane/Parameters.h | 4 ---- ArduPlane/system.cpp | 4 ---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ArduPlane/Parameters.cpp b/ArduPlane/Parameters.cpp index 113539dd17814b..639aa73039e6a2 100644 --- a/ArduPlane/Parameters.cpp +++ b/ArduPlane/Parameters.cpp @@ -1100,11 +1100,7 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { // @User: Advanced AP_GROUPINFO("FLIGHT_OPTIONS", 13, ParametersG2, flight_options, 0), -#if AP_SCRIPTING_ENABLED - // @Group: SCR_ - // @Path: ../libraries/AP_Scripting/AP_Scripting.cpp - AP_SUBGROUPINFO(scripting, "SCR_", 14, ParametersG2, AP_Scripting), -#endif + // 14 was AP_Scripting // @Param: TKOFF_ACCEL_CNT // @DisplayName: Takeoff throttle acceleration count @@ -1568,6 +1564,20 @@ void Plane::load_parameters(void) AP_Param::convert_class(info.old_key, &stats, stats.var_info, old_index, old_top_element, false); } #endif + // PARAMETER_CONVERSION - Added: Jan-2024 for Plane-4.6 +#if AP_SCRIPTING_ENABLED + { + // Find G2's Top Level Key + AP_Param::ConversionInfo info; + if (!AP_Param::find_top_level_key_by_pointer(&g2, info.old_key)) { + return; + } + + const uint16_t old_index = 14; // Old parameter index in g2 + const uint16_t old_top_element = 78; // Old group element in the tree for the first subgroup element (see AP_PARAM_KEY_DUMP) + AP_Param::convert_class(info.old_key, &scripting, scripting.var_info, old_index, old_top_element, false); + } +#endif hal.console->printf("load_all took %uus\n", (unsigned)(micros() - before)); } diff --git a/ArduPlane/Parameters.h b/ArduPlane/Parameters.h index 4a80e21943962d..ad78f76de7e216 100644 --- a/ArduPlane/Parameters.h +++ b/ArduPlane/Parameters.h @@ -519,10 +519,6 @@ class ParametersG2 { AP_Int32 flight_options; -#if AP_SCRIPTING_ENABLED - AP_Scripting scripting; -#endif // AP_SCRIPTING_ENABLED - AP_Int8 takeoff_throttle_accel_count; AP_Int8 takeoff_timeout; diff --git a/ArduPlane/system.cpp b/ArduPlane/system.cpp index 4b46bd837dd58a..56998c367904db 100644 --- a/ArduPlane/system.cpp +++ b/ArduPlane/system.cpp @@ -176,10 +176,6 @@ void Plane::startup_ground(void) ); #endif -#if AP_SCRIPTING_ENABLED - g2.scripting.init(); -#endif // AP_SCRIPTING_ENABLED - // reset last heartbeat time, so we don't trigger failsafe on slow // startup gcs().sysid_myggcs_seen(AP_HAL::millis()); From 78e37198351b1d5f4b6163072f0bbb14880c2cb0 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 30 Jan 2024 14:24:44 +1100 Subject: [PATCH 09/18] Copter: move scripting up to AP_Vehicle --- ArduCopter/Parameters.cpp | 20 +++++++++++++++----- ArduCopter/Parameters.h | 4 ---- ArduCopter/system.cpp | 4 ---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ArduCopter/Parameters.cpp b/ArduCopter/Parameters.cpp index 3da28c69432518..4318da61e084e4 100644 --- a/ArduCopter/Parameters.cpp +++ b/ArduCopter/Parameters.cpp @@ -913,11 +913,7 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { AP_SUBGROUPPTR(autotune_ptr, "AUTOTUNE_", 29, ParametersG2, AutoTune), #endif -#if AP_SCRIPTING_ENABLED - // @Group: SCR_ - // @Path: ../libraries/AP_Scripting/AP_Scripting.cpp - AP_SUBGROUPINFO(scripting, "SCR_", 30, ParametersG2, AP_Scripting), -#endif + // 30 was AP_Scripting // @Param: TUNE_MIN // @DisplayName: Tuning minimum @@ -1392,6 +1388,20 @@ void Copter::load_parameters(void) AP_Param::convert_class(info.old_key, &stats, stats.var_info, old_index, old_top_element, false); } #endif + // PARAMETER_CONVERSION - Added: Jan-2024 for Copter-4.6 +#if AP_SCRIPTING_ENABLED + { + // Find G2's Top Level Key + AP_Param::ConversionInfo info; + if (!AP_Param::find_top_level_key_by_pointer(&g2, info.old_key)) { + return; + } + + const uint16_t old_index = 30; // Old parameter index in g2 + const uint16_t old_top_element = 94; // Old group element in the tree for the first subgroup element (see AP_PARAM_KEY_DUMP) + AP_Param::convert_class(info.old_key, &scripting, scripting.var_info, old_index, old_top_element, false); + } +#endif hal.console->printf("load_all took %uus\n", (unsigned)(micros() - before)); diff --git a/ArduCopter/Parameters.h b/ArduCopter/Parameters.h index 5ac04f8946c608..c797f86cfe1aaf 100644 --- a/ArduCopter/Parameters.h +++ b/ArduCopter/Parameters.h @@ -600,10 +600,6 @@ class ParametersG2 { void *autotune_ptr; #endif -#if AP_SCRIPTING_ENABLED - AP_Scripting scripting; -#endif // AP_SCRIPTING_ENABLED - AP_Float tuning_min; AP_Float tuning_max; diff --git a/ArduCopter/system.cpp b/ArduCopter/system.cpp index ec167d96480adc..01d9d6d0ed1f02 100644 --- a/ArduCopter/system.cpp +++ b/ArduCopter/system.cpp @@ -179,10 +179,6 @@ void Copter::init_ardupilot() startup_INS_ground(); -#if AP_SCRIPTING_ENABLED - g2.scripting.init(); -#endif // AP_SCRIPTING_ENABLED - #if AC_CUSTOMCONTROL_MULTI_ENABLED == ENABLED custom_control.init(); #endif From b315192dcf30aa7109b468e453a5c4f4a63506ec Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 30 Jan 2024 14:53:43 +1100 Subject: [PATCH 10/18] Rover: move scripting up to AP_Vehicle --- Rover/Parameters.cpp | 20 +++++++++++++++----- Rover/Parameters.h | 4 ---- Rover/system.cpp | 4 ---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Rover/Parameters.cpp b/Rover/Parameters.cpp index 3481b7ea49acbf..1c7ae1a07b2a65 100644 --- a/Rover/Parameters.cpp +++ b/Rover/Parameters.cpp @@ -601,11 +601,7 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { // @User: Standard AP_GROUPINFO("BAL_PITCH_TRIM", 40, ParametersG2, bal_pitch_trim, 0), -#if AP_SCRIPTING_ENABLED - // @Group: SCR_ - // @Path: ../libraries/AP_Scripting/AP_Scripting.cpp - AP_SUBGROUPINFO(scripting, "SCR_", 41, ParametersG2, AP_Scripting), -#endif + // 41 was Scripting // @Param: STICK_MIXING // @DisplayName: Stick Mixing @@ -933,5 +929,19 @@ void Rover::load_parameters(void) AP_Param::convert_class(stats_info.old_key, &stats, stats.var_info, stats_old_index, stats_old_top_element, false); } #endif + // PARAMETER_CONVERSION - Added: Jan-2024 for Rover-4.6 +#if AP_SCRIPTING_ENABLED + { + // Find G2's Top Level Key + AP_Param::ConversionInfo scripting_info; + if (!AP_Param::find_top_level_key_by_pointer(&g2, scripting_info.old_key)) { + return; + } + + const uint16_t scripting_old_index = 41; // Old parameter index in g2 + const uint16_t scripting_old_top_element = 105; // Old group element in the tree for the first subgroup element (see AP_PARAM_KEY_DUMP) + AP_Param::convert_class(scripting_info.old_key, &scripting, scripting.var_info, scripting_old_index, scripting_old_top_element, false); + } +#endif } diff --git a/Rover/Parameters.h b/Rover/Parameters.h index e8dbb86a0eb249..ef8d6194706ac3 100644 --- a/Rover/Parameters.h +++ b/Rover/Parameters.h @@ -396,10 +396,6 @@ class ParametersG2 { // stick mixing for auto modes AP_Int8 stick_mixing; -#if AP_SCRIPTING_ENABLED - AP_Scripting scripting; -#endif // AP_SCRIPTING_ENABLED - // waypoint navigation AR_WPNav_OA wp_nav; diff --git a/Rover/system.cpp b/Rover/system.cpp index f358aee5b76486..67f0a8ebdfcbb3 100644 --- a/Rover/system.cpp +++ b/Rover/system.cpp @@ -174,10 +174,6 @@ void Rover::startup_ground(void) FUNCTOR_BIND(&rover, &Rover::Log_Write_Vehicle_Startup_Messages, void) ); #endif - -#if AP_SCRIPTING_ENABLED - g2.scripting.init(); -#endif // AP_SCRIPTING_ENABLED } // update the ahrs flyforward setting which can allow From 00bca3499fec990eebf37ee20f0261576453bf6c Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 30 Jan 2024 15:06:21 +1100 Subject: [PATCH 11/18] Sub: move scripting up to AP_Vehicle --- ArduSub/Parameters.cpp | 20 +++++++++++++++----- ArduSub/Parameters.h | 7 ------- ArduSub/system.cpp | 4 ---- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/ArduSub/Parameters.cpp b/ArduSub/Parameters.cpp index c87897b83b5cdb..168990b01f4c82 100644 --- a/ArduSub/Parameters.cpp +++ b/ArduSub/Parameters.cpp @@ -713,11 +713,7 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { // @Path: ../libraries/RC_Channel/RC_Channels_VarInfo.h AP_SUBGROUPINFO(rc_channels, "RC", 17, ParametersG2, RC_Channels), -#if AP_SCRIPTING_ENABLED - // @Group: SCR_ - // @Path: ../libraries/AP_Scripting/AP_Scripting.cpp - AP_SUBGROUPINFO(scripting, "SCR_", 18, ParametersG2, AP_Scripting), -#endif + // 18 was scripting // 19 was airspeed @@ -803,6 +799,20 @@ void Sub::load_parameters() const uint16_t stats_old_top_element = 4033; // Old group element in the tree for the first subgroup element (see AP_PARAM_KEY_DUMP) AP_Param::convert_class(stats_info.old_key, &stats, stats.var_info, stats_old_index, stats_old_top_element, false); } +#endif + // PARAMETER_CONVERSION - Added: Jan-2024 +#if AP_SCRIPTING_ENABLED + { + // Find G2's Top Level Key + AP_Param::ConversionInfo scripting_info; + if (!AP_Param::find_top_level_key_by_pointer(&g2, scripting_info.old_key)) { + return; + } + + const uint16_t scripting_old_index = 18; // Old parameter index in g2 + const uint16_t scripting_old_top_element = 82; // Old group element in the tree for the first subgroup element (see AP_PARAM_KEY_DUMP) + AP_Param::convert_class(scripting_info.old_key, &scripting, scripting.var_info, scripting_old_index, scripting_old_top_element, false); + } #endif } diff --git a/ArduSub/Parameters.h b/ArduSub/Parameters.h index 1e0b86a4e52409..f8fd851fbf5e11 100644 --- a/ArduSub/Parameters.h +++ b/ArduSub/Parameters.h @@ -7,10 +7,6 @@ #include #include -#if AP_SCRIPTING_ENABLED -#include -#endif - // Global parameter class. // class Parameters { @@ -372,9 +368,6 @@ class ParametersG2 { // control over servo output ranges SRV_Channels servo_channels; -#if AP_SCRIPTING_ENABLED - AP_Scripting scripting; -#endif // AP_SCRIPTING_ENABLED }; extern const AP_Param::Info var_info[]; diff --git a/ArduSub/system.cpp b/ArduSub/system.cpp index c3653f077cc2fe..f86637c5a143ab 100644 --- a/ArduSub/system.cpp +++ b/ArduSub/system.cpp @@ -157,10 +157,6 @@ void Sub::init_ardupilot() startup_INS_ground(); -#if AP_SCRIPTING_ENABLED - g2.scripting.init(); -#endif // AP_SCRIPTING_ENABLED - // enable CPU failsafe mainloop_failsafe_enable(); From b69c51a2963509bd4266a0894c402158c741bc3f Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 30 Jan 2024 15:26:59 +1100 Subject: [PATCH 12/18] Blimp: move scripting up to AP_Vehicle --- Blimp/Parameters.cpp | 20 +++++++++++++++----- Blimp/Parameters.h | 5 ----- Blimp/system.cpp | 4 ---- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Blimp/Parameters.cpp b/Blimp/Parameters.cpp index d231274847d6be..f0641e0cf28229 100644 --- a/Blimp/Parameters.cpp +++ b/Blimp/Parameters.cpp @@ -807,11 +807,7 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { // @User: Standard AP_GROUPINFO("PILOT_SPEED_DN", 24, ParametersG2, pilot_speed_dn, 0), -#if AP_SCRIPTING_ENABLED - // @Group: SCR_ - // @Path: ../libraries/AP_Scripting/AP_Scripting.cpp - AP_SUBGROUPINFO(scripting, "SCR_", 30, ParametersG2, AP_Scripting), -#endif + // 30 was AP_Scripting // @Param: FS_VIBE_ENABLE // @DisplayName: Vibration Failsafe enable @@ -884,6 +880,20 @@ void Blimp::load_parameters(void) AP_Param::convert_class(info.old_key, &stats, stats.var_info, old_index, old_top_element, false); } #endif + // PARAMETER_CONVERSION - Added: Jan-2024 for Copter-4.6 +#if AP_SCRIPTING_ENABLED + { + // Find G2's Top Level Key + AP_Param::ConversionInfo info; + if (!AP_Param::find_top_level_key_by_pointer(&g2, info.old_key)) { + return; + } + + const uint16_t old_index = 30; // Old parameter index in g2 + const uint16_t old_top_element = 94; // Old group element in the tree for the first subgroup element (see AP_PARAM_KEY_DUMP) + AP_Param::convert_class(info.old_key, &scripting, scripting.var_info, old_index, old_top_element, false); + } +#endif hal.console->printf("load_all took %uus\n", (unsigned)(micros() - before)); diff --git a/Blimp/Parameters.h b/Blimp/Parameters.h index 3d44b579a28101..769e9d2df7a4ad 100644 --- a/Blimp/Parameters.h +++ b/Blimp/Parameters.h @@ -305,11 +305,6 @@ class ParametersG2 // Land alt final stage AP_Int16 land_alt_low; - -#if AP_SCRIPTING_ENABLED - AP_Scripting scripting; -#endif // AP_SCRIPTING_ENABLED - // vibration failsafe enable/disable AP_Int8 fs_vibe_enabled; diff --git a/Blimp/system.cpp b/Blimp/system.cpp index dc3799a74a410d..5bde10d45bb60f 100644 --- a/Blimp/system.cpp +++ b/Blimp/system.cpp @@ -79,10 +79,6 @@ void Blimp::init_ardupilot() startup_INS_ground(); -#if AP_SCRIPTING_ENABLED - g2.scripting.init(); -#endif // AP_SCRIPTING_ENABLED - ins.set_log_raw_bit(MASK_LOG_IMU_RAW); // setup fin output From 9919af69bcc19fec2facdf4fdb1b4b29a673fdc7 Mon Sep 17 00:00:00 2001 From: bugobliterator Date: Fri, 12 Jan 2024 19:08:24 +1100 Subject: [PATCH 13/18] AP_HAL_ChibiOS: add config to enable sccripting on CANMod --- libraries/AP_HAL_ChibiOS/hwdef/CubePilot-CANMod/hwdef.dat | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/AP_HAL_ChibiOS/hwdef/CubePilot-CANMod/hwdef.dat b/libraries/AP_HAL_ChibiOS/hwdef/CubePilot-CANMod/hwdef.dat index 4994a739fb77af..965cd4462cba1e 100644 --- a/libraries/AP_HAL_ChibiOS/hwdef/CubePilot-CANMod/hwdef.dat +++ b/libraries/AP_HAL_ChibiOS/hwdef/CubePilot-CANMod/hwdef.dat @@ -85,11 +85,13 @@ define HAL_DISABLE_LOOP_DELAY ################################# define HAL_BARO_ALLOW_INIT_NO_BARO -define AP_RC_CHANNEL_ENABLED 1 define AP_INERTIALSENSOR_ENABLED 0 define AP_NETWORKING_MAX_INSTANCES 4 +define AP_SCRIPTING_ENABLED 1 +define AP_FILESYSTEM_ROMFS_ENABLED 1 + # listen for reboot command from uploader.py script # undefine to disable. Use -1 to allow on all ports, otherwise serial number index defined in SERIAL_ORDER starting at 0 define HAL_PERIPH_LISTEN_FOR_SERIAL_UART_REBOOT_CMD_PORT 0 From 85a8b6c414a10bc4ceb1c1b62bdcb5fb6559e2c8 Mon Sep 17 00:00:00 2001 From: Hayden Donald Date: Wed, 7 Feb 2024 14:30:44 +1100 Subject: [PATCH 14/18] AP_Scripting: Add filesystem format Added the ability to format the SD card from LUA --- libraries/AP_Scripting/docs/docs.lua | 9 ++++++++- .../AP_Scripting/generator/description/bindings.desc | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Scripting/docs/docs.lua b/libraries/AP_Scripting/docs/docs.lua index 0d4ac3d3a7d1d7..5a6589610b742c 100644 --- a/libraries/AP_Scripting/docs/docs.lua +++ b/libraries/AP_Scripting/docs/docs.lua @@ -1221,7 +1221,6 @@ compass = {} ---@return boolean function compass:healthy(instance) end - -- desc ---@class camera camera = {} @@ -3372,6 +3371,14 @@ fs = {} ---@return stat_t_ud|nil function fs:stat(param1) end +-- Format the SD card. This is a async operation, use get_format_status to get the status of the format +---@return boolean +function fs:format() end + +-- Get the current status of a format. 0=NOT_STARTED, 1=PENDING, 2=IN_PROGRESS, 3=SUCCESS, 4=FAILURE +---@return number +function fs:get_format_status() end + -- desc ---@class networking networking = {} diff --git a/libraries/AP_Scripting/generator/description/bindings.desc b/libraries/AP_Scripting/generator/description/bindings.desc index 0eee97bf20d509..c608870c879f51 100644 --- a/libraries/AP_Scripting/generator/description/bindings.desc +++ b/libraries/AP_Scripting/generator/description/bindings.desc @@ -881,6 +881,8 @@ userdata AP_Filesystem::stat_t method is_directory boolean singleton AP_Filesystem rename fs singleton AP_Filesystem method stat boolean string AP_Filesystem::stat_t'Null +singleton AP_Filesystem method format boolean +singleton AP_Filesystem method get_format_status uint8_t'skip_check include AP_RTC/AP_RTC.h depends AP_RTC_ENABLED include AP_RTC/AP_RTC_config.h From 14aea255e6dc54b19909b33132505370d4d9a369 Mon Sep 17 00:00:00 2001 From: Hayden Donald Date: Thu, 16 Nov 2023 11:40:05 +1100 Subject: [PATCH 15/18] AP_Scripting: Add calibrating method Add the calibrating method to lua so we can see if the device is currently calibrating --- libraries/AP_Scripting/docs/docs.lua | 4 ++++ libraries/AP_Scripting/generator/description/bindings.desc | 1 + 2 files changed, 5 insertions(+) diff --git a/libraries/AP_Scripting/docs/docs.lua b/libraries/AP_Scripting/docs/docs.lua index 5a6589610b742c..ebbe49d515a7d6 100644 --- a/libraries/AP_Scripting/docs/docs.lua +++ b/libraries/AP_Scripting/docs/docs.lua @@ -1505,6 +1505,10 @@ function ins:get_gyro_health(instance) end ---@return boolean function ins:get_accel_health(instance) end +-- Get if the INS is currently calibrating +---@return boolean +function ins:calibrating() end + -- desc ---@class Motors_dynamic Motors_dynamic = {} diff --git a/libraries/AP_Scripting/generator/description/bindings.desc b/libraries/AP_Scripting/generator/description/bindings.desc index c608870c879f51..951f1757570e49 100644 --- a/libraries/AP_Scripting/generator/description/bindings.desc +++ b/libraries/AP_Scripting/generator/description/bindings.desc @@ -633,6 +633,7 @@ singleton AP_InertialSensor rename ins singleton AP_InertialSensor method get_temperature float uint8_t 0 INS_MAX_INSTANCES singleton AP_InertialSensor method get_gyro_health boolean uint8_t'skip_check singleton AP_InertialSensor method get_accel_health boolean uint8_t'skip_check +singleton AP_InertialSensor method calibrating boolean singleton CAN manual get_device lua_get_CAN_device 1 singleton CAN manual get_device2 lua_get_CAN_device2 1 From 43a8432936b4056528ad7baa572317eb1dbac44f Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Tue, 6 Feb 2024 20:37:09 +0000 Subject: [PATCH 16/18] vscode: set lua version to 5.3 --- .vscode/settings.default.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.default.json b/.vscode/settings.default.json index d6469cb6b6bae8..1a5ba955dd21ab 100644 --- a/.vscode/settings.default.json +++ b/.vscode/settings.default.json @@ -1,4 +1,5 @@ { "cSpell.language": "en-GB", - "astyle.astylerc": "${workspaceFolder}/Tools/CodeStyle/astylerc" + "astyle.astylerc": "${workspaceFolder}/Tools/CodeStyle/astylerc", + "Lua.runtime.version": "Lua 5.3" } From 5b6d86c278356c655d6cb62d58532eee8931d96c Mon Sep 17 00:00:00 2001 From: Iampete1 Date: Tue, 6 Feb 2024 14:59:08 +0000 Subject: [PATCH 17/18] AP_Parachute: do relay conversion if ever enabled --- libraries/AP_Parachute/AP_Parachute.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Parachute/AP_Parachute.cpp b/libraries/AP_Parachute/AP_Parachute.cpp index aae6ea9bc9b942..c570f8bf6cfa85 100644 --- a/libraries/AP_Parachute/AP_Parachute.cpp +++ b/libraries/AP_Parachute/AP_Parachute.cpp @@ -241,7 +241,17 @@ bool AP_Parachute::arming_checks(size_t buflen, char *buffer) const bool AP_Parachute::get_legacy_relay_index(int8_t &index) const { // PARAMETER_CONVERSION - Added: Dec-2023 - if (!enabled() || (_release_type > AP_PARACHUTE_TRIGGER_TYPE_RELAY_3)) { + if (_release_type > AP_PARACHUTE_TRIGGER_TYPE_RELAY_3) { + // Not relay type + return false; + } + if (!enabled() && !_enabled.configured()) { + // Disabled and parameter never changed + // Copter manual parachute release enables and deploys in one step + // This means it is possible for parachute to still function correctly if disabled at boot + // Checking if the enable param is configured means the user must have setup chute at some point + // this means relay parm conversion will be done if parachute has ever been enabled + // Parachute has priority in relay param conversion, so this might mean we overwrite some other function return false; } index = _release_type; From ae19d032ce73fdbf4eb7c375079244131b24babb Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 6 Feb 2024 10:14:53 +1100 Subject: [PATCH 18/18] AP_RCProtocol: use constructor from parent class in ibus --- libraries/AP_RCProtocol/AP_RCProtocol_IBUS.cpp | 5 ----- libraries/AP_RCProtocol/AP_RCProtocol_IBUS.h | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/libraries/AP_RCProtocol/AP_RCProtocol_IBUS.cpp b/libraries/AP_RCProtocol/AP_RCProtocol_IBUS.cpp index bf286f8985aaec..d35d12d0e2b434 100644 --- a/libraries/AP_RCProtocol/AP_RCProtocol_IBUS.cpp +++ b/libraries/AP_RCProtocol/AP_RCProtocol_IBUS.cpp @@ -20,11 +20,6 @@ #include "AP_RCProtocol_IBUS.h" -// constructor -AP_RCProtocol_IBUS::AP_RCProtocol_IBUS(AP_RCProtocol &_frontend) : - AP_RCProtocol_Backend(_frontend) -{} - // decode a full IBUS frame bool AP_RCProtocol_IBUS::ibus_decode(const uint8_t frame[IBUS_FRAME_SIZE], uint16_t *values, bool *ibus_failsafe) { diff --git a/libraries/AP_RCProtocol/AP_RCProtocol_IBUS.h b/libraries/AP_RCProtocol/AP_RCProtocol_IBUS.h index b3e759781662ae..179eb22e22032b 100644 --- a/libraries/AP_RCProtocol/AP_RCProtocol_IBUS.h +++ b/libraries/AP_RCProtocol/AP_RCProtocol_IBUS.h @@ -30,7 +30,8 @@ class AP_RCProtocol_IBUS : public AP_RCProtocol_Backend { public: - AP_RCProtocol_IBUS(AP_RCProtocol &_frontend); + using AP_RCProtocol_Backend::AP_RCProtocol_Backend; + void process_pulse(uint32_t width_s0, uint32_t width_s1) override; void process_byte(uint8_t byte, uint32_t baudrate) override; private: