Lua scripting on AP_Periph

Does anyone have any tips on getting Lua scripts running on AP_Periph? I want to add some really basic read/write GPIO logic using Lua scripts to an AP_Periph device, but I can’t quite get the script to work and I’m wondering if there is any additional configuration for AP_Periph scripting that needs to be done apart from what is done on other more capable verisons of ardupilot. I’m using a STM32F767 so I should be meeting all the hardware requirements for scripting.

Do you have SCR_ENABLE parameter? If not you have to build a binary with scripting enabled. If your board doesn’t have SD card slot you also will have to bake the script into the firmware as described in Lua documentation.

I did have the SCR_ENABLED parameter enabled and I was embedding my script into the ROMFS. I was able to figure out why the Lua script didn’t seem to be running though. AP_Periph doesn’t have the ROM filesystem set up out of the box, so I needed to add “define AP_FILESYSTEM_ROMFS_ENABLED 1” to the hwdef.dat so that the Lua script could actually embed itself into the firmware. Once I did that, everything started working.

4 Likes