Getting started - question about pre-compiled LUA

Greetings -

I’ve decided to learn LUA and how it’s implemented on ArduPilot. I’ll probably also take a look at how it’s implemented on OpenTX.

I’ve found several acceptable reference texts, established a git repository, installed GIT, and Visual Studio Code as an IDE.

Seemed to me the easiest way to get some code samples was to clone Yaapu - so I’ve done that. Interesting - I hadn’t realized that LUA could be pre-compiled.

I tried running a Yaapu pre-compiled script on my computer that’s running LUA 5.3.6 - it gave an error because of a version problem.

So it seems OpenTX runs some other version of LUA - and I need to watch out for version compatibility if I pre-compile lua chunks.

I was told that ArduCopter supports LUA 5.3.5. I’ll be interested to find out of it also support pre-compiled code - and if version issues exist.

I’m looking forward to being more involved.

Lua is an interpreted scripting language. It is generally “compiled” at runtime, though there is a compiler that can generate binaries. Though Lua binaries are slightly more portable than some other architectures, those compiled for OpenTX are highly likely to be incompatible with PC architecture unless you’re running a simulator or emulator like the one included with OpenTX Companion.

At any rate, the ArduPilot Lua interpreter is somewhat unique, as is the OpenTX one.If you want to learn scripting for ArduPilot, OpenTX (where the Yaapu scripts run) is not the place to start. If you just want to learn Lua in general, is the place to be.

For ArduPilot:

Watch this video. I also published a video on the topic.

Read this documentation and recognize that it is a bit behind development, as I know you’ve already discovered elsewhere…

Dig into the examples.

At present, I don’t know of a way to use precompiled Lua binaries with ArduPilot, nor is there likely much advantage in doing so. The scripts are loaded and interpreted at boot time with no further processing power devoted to “compilation” type tasks after that. I suppose there may be an argument for precompiled binaries if you wanted to try and cram Lua scripting onto a less fully featured autopilot than presently supported, but there are likely other obstacles there.

1 Like

Thank you Yuri - for all the great references! I look forward to studying them.

LUA reminds me of the languages used to teach students programming back in the 70’s - I recall seeing languages like LUA on UNIX running on PDP/1170’s when I was an undergraduate at Berkeley. Those were the days…

The syntax looks simple enough - but as always - the devil is in the details. Hence - the importance of some of your comments.

I look forward to being a contributor on the subject when I get up to speed. Thanks again for the references!

1 Like