About the ArduPilot Lua Scripting category

ArduPilot has introduced support for Lua scripting. Scripting provides a safe, “sandboxed” environment for new behaviours to be added to the autopilot without modifying the core flight code. Scripts are stored on the SD card and run in parallel with the flight code.

This category is for users and developers to share and discuss Lua scripting in ArduPilot.
To use scripting, you’ll need a flight controller with 2MB of flash.
Start here: https://ardupilot.org/copter/docs/common-lua-scripts.html for an overview and setup guide.
Sample scripts are here: https://github.com/ArduPilot/ardupilot/tree/master/libraries/AP_Scripting/examples

5 Likes

Nice to see a dedicated area for this. Thanks guys

I have been trying to play a little bit with lua scripting on my black cube but once i enable it, it does all kind of strange stuff. Probably F7, H7 boards are minimum to safely use lua?
For example, if i enable scripting on my black cube i get “already got param” going forever when i try to connect it to MP. Maybe i should disable something on it but all there is loaded now it is needed.

Corrado

hiii,
i am trying to do scripting but unable to do it, could you please guide me.

https://ardupilot.org/copter/docs/common-lua-scripts.html

Google gives me in search:
https://ardupilot.org/copter/docs/common-lua-scripts.html

I go to this page and see:

Error when establishing a secure connection
An error occurred while connecting to ardupilot.org. PR_CONNECT_RESET_ERROR
Error code: PR_CONNECT_RESET_ERROR
The page you are trying to view cannot be displayed because the data received cannot be verified.
Please contact the website owners and let them know about this issue.

What am I doing wrong ?

I have been programming in Assembly and C for microprocessors for many years.
Now, I want to understand what “programming in Lua scripts for Ardupilot” is.
I have a task to make a complex take-off program for my glider.

But I don’t understand how pieces of code that are unclear will help me:

  1. what should a Lua script program look like?
  2. beginning, body of the program, completion?
  3. Syntax of commands and operations?
  4. acceptable variables, functions (full name and list with descriptions)?
  5. examples of programs (at least the simplest ones)?

Lua Scripts — Copter documentation – doesn’t work at all…
Please help me make sense of all this.
Are there any books on Lua?
How does the Lua language itself work (what is provided) inside Ardupilot?

this following Lua script code does not work, how do I do single-line multiple operations?

res = res or gps_z_pos:set(-0.14)

When and how user choose and use set and set_and_save?