From 1420ac868d500ea8caf7fb883b396450691ede4a Mon Sep 17 00:00:00 2001 From: Michael du Breuil Date: Thu, 28 Feb 2019 23:40:40 -0700 Subject: [PATCH] APMRover2: Allow scripting to run --- APMrover2/Parameters.cpp | 5 +++++ APMrover2/Parameters.h | 5 +++++ APMrover2/Rover.h | 5 +++++ APMrover2/system.cpp | 6 ++++++ 4 files changed, 21 insertions(+) diff --git a/APMrover2/Parameters.cpp b/APMrover2/Parameters.cpp index f060ae0b26..2694cc1f14 100644 --- a/APMrover2/Parameters.cpp +++ b/APMrover2/Parameters.cpp @@ -703,6 +703,11 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = { // @User: Standard AP_GROUPINFO("BAL_PITCH_TRIM", 40, ParametersG2, bal_pitch_trim, 0), +#ifdef ENABLE_SCRIPTING + // Scripting is intentionally not showing up in the parameter docs until it is a more standard feature + AP_SUBGROUPINFO(scripting, "SCR_", 41, ParametersG2, AP_Scripting), +#endif + AP_GROUPEND }; diff --git a/APMrover2/Parameters.h b/APMrover2/Parameters.h index 9e6881cc97..2de785b798 100644 --- a/APMrover2/Parameters.h +++ b/APMrover2/Parameters.h @@ -399,6 +399,11 @@ public: // balance both pitch trim AP_Float bal_pitch_trim; + +#ifdef ENABLE_SCRIPTING + AP_Scripting scripting; +#endif // ENABLE_SCRIPTING + }; extern const AP_Param::Info var_info[]; diff --git a/APMrover2/Rover.h b/APMrover2/Rover.h index d9a3a2ad96..95575082db 100644 --- a/APMrover2/Rover.h +++ b/APMrover2/Rover.h @@ -81,6 +81,11 @@ #include #include #include + +#ifdef ENABLE_SCRIPTING +#include +#endif + #if CONFIG_HAL_BOARD == HAL_BOARD_SITL #include #endif diff --git a/APMrover2/system.cpp b/APMrover2/system.cpp index 6bbba0ef3b..95ca1b99ce 100644 --- a/APMrover2/system.cpp +++ b/APMrover2/system.cpp @@ -196,6 +196,12 @@ void Rover::startup_ground(void) ); #endif +#ifdef ENABLE_SCRIPTING + if (!g2.scripting.init()) { + gcs().send_text(MAV_SEVERITY_ERROR, "Scripting failed to start"); + } +#endif // ENABLE_SCRIPTING + // we don't want writes to the serial port to cause us to pause // so set serial ports non-blocking once we are ready to drive serial_manager.set_blocking_writes_all(false);