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:

I have the same problem but in mp messages dont appear any error.

i have load in the scrips folder, the Helloworld.lua and scr_enable=1

[SCR_DEBUG_OPTS] have to set in any value? i have at 0

with SCR_DEBUG_OPTS=5 the error message appears Lua: No scripts to run

i dont have to make run any lua

have you got the scripts in the correct folder?

yes, APM/scripts folder

the bitmask of SCR_DEBUG_OPTS have to set in any value??

That script prints a single message to the GCS and exits. You’re probably just missing the message because you can’t connect the GCS fast enough to see it.

i connect direct usb to the cube and use mission planner.

there is a possible option you talk about. the hello world lua only send a single message.

but if i set the bitsmask of SCR_DEBUG_OPTS to 1, the system tells if there are any luas in curse. and all the moment tells “NO scripts to run”

its appear that the scripts dont run

there are any script to test the system thats output a repeated message each x seconds?

by the other hand…

if there are activated the scripts with SCR_Enable and you load a valid script in your folder,

at the startup of the system, dont appear the message "lua scripting ok? or any similar?

Show a screenshot of your scripting folder on the MAVFTP screen.


i try with different scripts and send me the same error.

Use the .lua extension. Not all caps.

Thanks you very much!

sorry for my “all caps file naming!” i dont know that the caps are forbidden for this files

the script works ok, therefore i can make more complicated scripts and make some test.

thank you very much