Ardupilot Lua
ardupilot use Lua version 5.3
ardupilot lua API
- Ardupilot API Documentation
- Ardupilot Lua API declare in
docs.lualocatelibraries/AP_Scripting/docs/docs.lua
Lua demo script
Can be found libraries/AP_Scripting/tests
Demo
Run lua script using SITL
- Create
scriptsfolder in SITL executable folder - Add
SCR_ENABLE=1parameter to param file - Place the lua script under the
scriptsfolder
| hello.lua | |
|---|---|
Parameters
| Parameter | Purpose | Typical Use |
|---|---|---|
SCR_ENABLE |
Enable Lua | Always set to 1 |
SCR_DIR_DISABLE |
Disable auto script loading | Rare |
SCR_HEAP_SIZE |
Memory for Lua | Increase if crash |
There more parameters for logging and debugging check documentation
Predefined parameters
SCR_USERx parameter are generic parameters meant exactly for Lua scripts.
| Parameter | Type | Purpose |
|---|---|---|
SCR_USER1 |
float | user-defined value |
SCR_USER2 |
float | user-defined value |
SCR_USER3 |
float | user-defined value |
SCR_USER4 |
float | user-defined value |
SCR_USER5 |
float | user-defined value |
SCR_USER6 |
float | user-defined value |
Custom parameter
VSCode
Using docs.lua
Get libraries/AP_Scripting/docs/docs.lua from ardupilot github (choose the right version)
- This file is not meant to run
- It’s a fake API definition for tooling (IntelliSense, completion)
| .vscode/settings.json | |
|---|---|