So I have been attempting to set up WS2813 strip LEDs to function as direction / status indicators for my quad using the Pixhawk 2.4.8 and Lua scripting. However I have been having some issues.
Firstly, I always see the ‘Lua: No scripts to run’ message regardless as to whether a Lua script is running or not.
I have had success running a simple ‘hello world’ script example taken from here: https://github.com/ArduPilot/ardupilot/tree/ArduPlane-stable/libraries/AP_Scripting/examples (although for some reason I got a syntax error for the commented line). However when I attempt to run the LED roll script I am faced with multiple Lua errors (that always seem to cut off after a certain amount of characters in Mission Planner’s Messages tab rather annoyingly).
Setting SERVO12_FUNCTION to 94 and running this basic LED test script:
local num_leds = 4
local vez = 0
local chan
chan = SRV_Channels:find_channel(94)
if not chan then
gcs:send_text(0, "LEDs: channel not set")
return
end
chan = chan + 1
gcs:send_text(0, "LEDs started.")
serialLED:set_num_LEDs(chan, num_leds)
function update_LEDs()
serialLED:set_RGB(chan, 1, 255, 255, 255)
serialLED:send()
return update_LEDs, 500
end
return update_LEDs, 500
I have attempted removing the variables and hard coding it but get the same error. It is very frustrating to debug as I can only see part of the error message!
As an aside, I was hoping to use the beta Mission Planner and MavFTP to upload my Lua scripts (instead of manually moving them across to the scripts folder in the SD card), however these are the only folders it gives me:
what version of Copter are you running?, the master examples only work on master, If you click on the unlabeled folder you should get to scripts i think
On MAVFtp I select the empty folder and at the bottom I see ‘/ Listing’, then a progress bar fills up until ‘/ Ready’, however with no files or folders showing.
I also keep coming across a problem with the beta version of Mission Planner whereby when connecting to the Pixhawk it gets stuck going through ‘Already Got param’ parameters?
@iampete I tried uploading the hello_world and LED_roll lua scripts from that link to the Pixhawk and both seemed to work straight away! The LED strip goes a solid green. I no longer see those ‘Lua: No scripts to run’ messages either. I will have to study the files more carefully!
@Webillo In the documentation and in the LED_roll example I just uploaded they don’t include a channel, so I am not sure if they changed it? I am running on channel 12 luckily but hadn’t realised you had to assign a channel for Neopixels?
Both of these things are in master but have not made it to stable yet
It is not currently possible to have some of the leds in one strip be NTF and others be scripting, really you need to use a different group other wise the send from the notify and scripting clash and send before the other is ready.
Hopefully we can fix this by making the notify rgb color available to scripting, then you can read out the notify color into the script and set them that way.
I was planning on having the two back strips controlled by a lua script and connected to one AUX channel whilst the front two strips are NTF LEDs and are controlled by a separate channel, so that should work fine for me! But it would be great if the NTF colour was made available for Lua scripting.
Is it possible for me to update my Arducopter to the master branch to get these features?
yep, cntrl + q on the mission planner load firmware screen, the notify length param should be coming to the next beta release. Note that the master firmware is less well tested so there might be bugs and it might do unexpected things
you should be using serialLED:set_num_neopixel if you have neopixles. Scripting is evolving very quickly hence the differences between stable and master.