
The script is allowed to specify a new callback function and time at which it should be called, which allows it to be run continuously. In order to allow multiple scripts to be run, each script is allocated a fixed time chunk (measured in VM instructions) in which it is expected to complete it’s processing. Scripts are run at a low priority on the system, which ensures that the core flight code will continue to execute even if a script is taking a long time to process. Lua is a garbage collected, imperative programming language. These features are usually enabled by default, set SRTL_POINTS = 0, TERRAIN_ENABLE = 0). On autopilots with a STM32F4 microcontroller, Smart RTL (Rover, Copter) and Terrain Following (Plane, Copter) need to be nearly always disabled. If set too high other autopilot features such as Terrain Following or even the EKF may fail to initialize. If this parameter is set too low, scripts may fail to run. The autopilot’s free memory depends highly upon which features and peripherals are enabled. The default of 43 kB is sufficient for small scripts and fits onto most autopilots.



SCR_HEAP_SIZE can be adjusted to increase or decrease the amount of memory available for scripts. Messages and errors are sent to the ground station and, if using Mission Planner, can be viewed in the Data screen’s “Messages” tab. When the autopilot is powered on it will load and start all scripts. In addition, four dedicated script parameters are available: SCR_USER1 thru SCR_USER4 and are accessed with the same method as any other parameter, but these are reserved for script use. Up to 8 RC channels can be assigned as scripting inputs/controls using the``RCX_OPTION`` = “300-307” options. For example, there is a script to allow a user to change a SmartAudio capable video transmitter’s output power level from a transmitter channel and set its power-up value via parameter. md file of the same name detailing its capabilities, use, and setup. The latest development scripts can be found here.Īpplets which are scripts that require no user editing before use, can be found here. Sample Scripts can be found here for stable Plane, Copter and Rover. If using a simulator, the scripts folder is in the directory the simulator was started from.If using Mission Planner, this can be done using MAVFTP.This folder can also be created manually on the SD card. If this folder does not exist, you can create it by setting SCR_ENABLE to 1 and rebooting.lua) to the autopilot’s SD card’s APM/scripts folder. Set SCR_ENABLE to 1 to enable scripting (refresh or reboot to see all SCR_ parameters). High powered autopilots like the CubePilot Cube Orange and HolyBro Durandal will certainly work well but check the specifications of your autopilot. Ensure your autopilot has at least 2 MB of flash and 70 kB of memory.
