Plane: Create a scripting object

This commit is contained in:
Michael du Breuil 2018-09-27 16:03:56 -07:00 committed by Andrew Tridgell
parent a7d94ff6c7
commit 3aed07a83a
4 changed files with 19 additions and 0 deletions

View File

@ -1177,6 +1177,11 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = {
// @User: Advanced
AP_GROUPINFO("FLIGHT_OPTIONS", 13, ParametersG2, flight_options, 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_", 14, ParametersG2, AP_Scripting),
#endif
AP_GROUPEND
};

View File

@ -545,6 +545,10 @@ public:
#endif
AP_Int32 flight_options;
#ifdef ENABLE_SCRIPTING
AP_Scripting scripting;
#endif // ENABLE_SCRIPTING
};
extern const AP_Param::Info var_info[];

View File

@ -108,6 +108,10 @@
// Local modules
#include "defines.h"
#ifdef ENABLE_SCRIPTING
#include <AP_Scripting/AP_Scripting.h>
#endif
#include "RC_Channel.h" // RC Channel Library
#include "Parameters.h"
#include "avoidance_adsb.h"

View File

@ -251,6 +251,12 @@ void Plane::startup_ground(void)
);
#endif
#ifdef ENABLE_SCRIPTING
if (!g2.scripting.init()) {
gcs().send_text(MAV_SEVERITY_ERROR, "Scripting failed to start");
}
#endif // ENABLE_SCRIPTING
// reset last heartbeat time, so we don't trigger failsafe on slow
// startup
failsafe.last_heartbeat_ms = millis();