diff --git a/libraries/AP_Vehicle/AP_Vehicle.cpp b/libraries/AP_Vehicle/AP_Vehicle.cpp index c138c19d79..fcb78c2799 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 32e0f3150c..3e38ac9b63 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 @@ protected: 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[];