Cannot get lua scripts running

Hello. I am a bit lost. I have for the last two days tried to get lua scripts running on ardupilot.

  • I have tried latest stable fw 4.2.x and latest 4.2 dev (on both plane and copter).
  • I have tried the above FW’s on 3 different FC boards (3dr Pixhavk1, Pixhawk cube black and Holybro PH4 mini).
  • I have tried on both a clean install like shown below and on the FC in my Mini Talon VTOL
  • I have enabled lua scripts and uploaded the .lua files to the scripts folder on the FC (tried both direct to sd-card and through MAVFtp).
  • I have disabled Terrain and checked that there is enough space allocated for lua scripts (scr_heap_size) and verified that there is enough free memory. All OK as far as I can see.
  • I have tried different scripts including the the simpler ones like “hello_world.lua” (the one I wanted was the “vtol_quicktune”)

I always get the error (name dependent on what lua I try): “Lua: Error: /APM/scripts/hello_world.lua:8: unexpe”

I have tried to search for this error code without luck. I have a feeling that I it is something easy and stupid I missing, but I am sort of lost…

image
image

You have done everything correctly, but there is a syntax error on line 8 of your script.

Thanks for looking into it. What you say sounds a bit strange to me as these are premade scripts from the Ardupulot GitHub, and I have tried 4 different scripts on 3 different flight controllers with the same error message. Hmmmmm.

Post the exact script you are using (drop the file into a post as an attachment). Sometimes the examples are version specific.

If you are using this hello_world.lua, you have done something very strange indeed. There are only 3 lines, and the '<' character appears nowhere. Did you perhaps save the entire HTML contents of a GitHub page? Doing so would result in a file that looks like this, with that exact error on line 8.

image

I have not locked at the file content but I feel that you are on to something. I might have done something as stupid as that :slight_smile:

I feel pretty stupid now. I had indeed saved the entire content of the page… As soon as I saved the correct content the scripts magically works :slight_smile:

Anyway thanks for helping me out. I will have to learn how to use the GitHub :slight_smile: