From cac4b91671d3844981f70c298ee0ec22bd2232ec Mon Sep 17 00:00:00 2001 From: Michael du Breuil Date: Thu, 28 Feb 2019 23:40:53 -0700 Subject: [PATCH] Copter: Allow scripting to run --- ArduCopter/Copter.h | 4 ++++ ArduCopter/Parameters.cpp | 5 +++++ ArduCopter/Parameters.h | 5 +++++ ArduCopter/system.cpp | 6 ++++++ 4 files changed, 20 insertions(+) diff --git a/ArduCopter/Copter.h b/ArduCopter/Copter.h index db5f5800a7..0241f23281 100644 --- a/ArduCopter/Copter.h +++ b/ArduCopter/Copter.h @@ -170,6 +170,10 @@ #include #endif +#ifdef ENABLE_SCRIPTING +#include +#endif + // Local modules #ifdef USER_PARAMS_ENABLED #include "UserParameters.h" diff --git a/ArduCopter/Parameters.cpp b/ArduCopter/Parameters.cpp index 5609dc507c..28ae87a981 100644 --- a/ArduCopter/Parameters.cpp +++ b/ArduCopter/Parameters.cpp @@ -929,6 +929,11 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { // @Path: ../libraries/AC_AutoTune/AC_AutoTune.cpp AP_SUBGROUPPTR(autotune_ptr, "AUTOTUNE_", 29, ParametersG2, Copter::AutoTune), #endif + +#ifdef ENABLE_SCRIPTING + // Scripting is intentionally not showing up in the parameter docs until it is a more standard feature + AP_SUBGROUPINFO(scripting, "SCR_", 30, ParametersG2, AP_Scripting), +#endif AP_GROUPEND }; diff --git a/ArduCopter/Parameters.h b/ArduCopter/Parameters.h index a05df886b0..a9d248f410 100644 --- a/ArduCopter/Parameters.h +++ b/ArduCopter/Parameters.h @@ -583,6 +583,11 @@ public: // we need a pointer to autotune for the G2 table void *autotune_ptr; #endif + +#ifdef ENABLE_SCRIPTING + AP_Scripting scripting; +#endif // ENABLE_SCRIPTING + }; extern const AP_Param::Info var_info[]; diff --git a/ArduCopter/system.cpp b/ArduCopter/system.cpp index d249f3a132..e530961a59 100644 --- a/ArduCopter/system.cpp +++ b/ArduCopter/system.cpp @@ -244,6 +244,12 @@ void Copter::init_ardupilot() startup_INS_ground(); +#ifdef ENABLE_SCRIPTING + if (!g2.scripting.init()) { + gcs().send_text(MAV_SEVERITY_ERROR, "Scripting failed to start"); + } +#endif // ENABLE_SCRIPTING + // set landed flags set_land_complete(true); set_land_complete_maybe(true);