Need help binding to Copter class

Hello everyone,

I have been working on some Lua scripts and it’s going quite well so far, but I have reached a roadblock. I am using Copter 4.4.3.

I am trying to bind to copter, because I need access to the pos_control and loiter objects.

As an initial test I wanted to see if I can bind to “void failsafe_check()” - a public function in Copter class.

Here is the code I added to bindings.desc (I will update docs.lua as well but in my experience bindings work fine without that)

include ../ArduCopter/Copter.h
ap_object Copter method failsafe_check void

Here is my test script:

-- test lua scripting
--[[ 
   trigger function -- determines if it is time to do something
]]
function trigger()

   Copter:failsafe_check()

   return trigger, 1000
end

-- start running the loop
return trigger()

When the script is ran I get the following error:

Lua: State memory usage: 4824 + 26341
Lua: ./scripts/test.lua:9: attempt to index a nil value (global 'Copter')
AP: Lua: ./scripts/test.lua:9: attempt to index a nil value (global 'Copter')

Please help

I have also tried the following (since the Copter instance is actually copter)

copter:failsafe_check()

I also tried the following since Copter extends AP_Vehicle which is a singleton,

include ../ArduCopter/Copter.h
singleton Copter method failsafe_check void

But then it complains about trying to convert AP_Vehicle* to Copter*.

Before I start hacking at it I figured someone may have a more elegant solution. Hopefully some of the brilliant minds here can help me with this.