Can’t read in parameters

Hi! I am trying to read in some parameters with my Lua script with the param:get(‘XYZ’)-function, but it’s not working. I only get this message:

Other scripts are running as expected. The problem is just the line to read in parameters.
I’ve reduced my script to basically just the line out of the example files:
local value = param:get(‘SCR_ENABLE’)
But it’s still not working. I’m using the Pixhawk 2.1 Cube black. Maybe it has to do something with the available memory? I also had the problem with downloading parameters, described here:

but could solve it now. Since I disabled terrain following, it seems to be working (more or less) fine. I still get a few “Already got param” messages, but it’s connecting to MissionPlanner.

I found out more about the error. If I use APM Planner 2 instead of MP, it’s showing me: “attempt to index a n” which means attempt to index a nil value , I guess. So if I understand that correctly that means, that the script can’t find the parameter it was looking for. But since I’m absolutely sure, that it is spelled correctly (I also tried other parameters), it has to do something with the location the parameters are stored in or how it is looking there. Is it working on your boards? I get the same error with two different boards (both cube black).

The bindings and examples on GitHub only work on the dev/master branch, check the copter 4.0 branch for the ones that will work for you (or use dev/master)

Hi Peter, thanks for your help!

I’m running ArduCopter V4.0.3 heli. Official Version. So what does that mean? It should actually work I guess, right?

no, you need latest.

1 Like

Ah okay. Thanks a lot!

I just wanted to confirm that it’s working now. Thanks again!

1 Like

Does anyone know, when Lua scripting (and the reading in of parameters) will work in the stable firmware version of ArduCopter? I’m flying a large traditional helicopter and don’t feel really comfortable loading the latest release on the flight controller. Though I really like the new possibilities coming with Lua scripting.

Hey Felix,
i have the same problem! I work only with the 4.1.0 but doesn’t with the Stable or Beta …

Unfortunately I don’t have a solution for that. I’m also still waiting for the release of 4.1.0 as Stable version. But I’m afraid that might take a while…

Oh yes, I’ve found out, if the script is smaller it works: Currently it is 5kB with 2.1kB it works

Are you sure? Are you reading in or changing parameters with param:get or param:set? I tried that with a super small 1,69 kB script. Not working. (But other things without the parameter functions are working.)