Lua Scripts using Velocity Control

well order parts to give this a go,also ordered back to front jacket and padded cell for when my 1/2 brain cell explodes think this will keep me occupied during these tough times thank you Randy im a happy OAP

1 Like

Hey @rmackay9
Had no luck with LED neopixel scripting on stable version. The latest master started accepting scripts on my Cube purple somehow. And it works. Thanks to @iampete for sample scripts.

Disclaimer: Donā€™t follow the servo rail power connection as shown in the video.

2 Likes

@Mallikarjun_SE,

OK, itā€™s very possible that the scripting support for LED control isnā€™t in the stable releases yet.
Great that you got it working and it should work with Copter-4.1.x if not earlier.

1 Like

Hey @iampete @rmackay9
Is there bindings for pre-arm check?
I was thinking to make led fast blink red when it hasnā€™t passed pre-arm checks and fast blink green when all pre-arm checks are passed.
Any suggestions?
Thank you.

1 Like

we do have a binding to perform a lua pre-arm check, you could check the loaded mission contains a take off and landing or what ever else and refuse to arm from from scripting.

I think what you want is to ask ArduPilot if it would pass checks and arm if you were to try now? We canā€™t do this currently, what would be nice is to read the notify state, so you can have custom LED notify patterns via scripting.

1 Like

Yes. It would be nice to read the notify state and output scripted LED pattern. I actually use a mavlink LED controller which does this when connected to telemetry. But itā€™s too much hardware inbetween for something which can be done through simple scripting.
I just want LEDs to display whether checks are passed. If yes, then blinking green. Else, blinking red.
Thank you.

1 Like

Hey @iampete
Can this binding be used?
ā€œsingleton AP_AHRS method prearm_healthy booleanā€

1 Like

That tells you if the AHRS is ready to arm, but you could still fail arming for other reasons, fail safes for example or low voltage. That might be good enough for your use case tho.

1 Like

Hey @iampete
I tried writing script for playing tune on high roll or pitch angle. Iā€™m not able to figure out threshold value. I read roll has to be in radians. I tried both in radians and degrees. It doesnā€™t work.
Am I missing something?
Thank you.

1 Like

@Mallikarjun_SE,

yes, roll and pitch will be in radians. So 90deg is 1.57. Pitch will never be >90degrees though. once it becomes >90 youā€™ll see that instead roll suddenly becomes around 180 and pitch becomes -90.

1 Like

Yes. I was doing bench test by giving various values. Iā€™m planning to set it for 30 degree on roll and pitch, so around 0.52 rad?
How does it vary? Will it be +0.52rad for left and -0.52rad to right?
Thank you.

2 Likes

Iā€™m in the advanced user model,but I cannot find SCR_ENABLE parameter.I donā€™t know why.Now Iā€™m trying rebrush firmware

@zthcool, I can imagine two possible reasons - first make sure that Copter-4.0.3 (or higher) is on the autopilot. Then I wonder if perhaps it is a Pixhawk autopilot which suffers from the 1Mb flash limit (a hardware issue with the STM CPU). Some older Pixhawks have this issue. If it is a Pixhawk then you could try directly downloading and then uploading the arducopter.apj file from the Pixhawk1 direction on firmware.ardupilot.org to see if that works.

WOW!! Amazing !!! YES Iā€™m using Pixhawk1,I upload the Rover 4.0 directly,and SCR_ENABLE appeared.Thank you very much.
And when I upload firmware just now with MP 1.3.71 in auto model,It cannot find comports when has been downloaded.But 1.3.70 works well.

Now the Lua Scripts is working.At first I only use USB to connect MP,It said ā€œNo scripts to runā€.Then I connected battery.It worked!

1 Like

Excellent, great stuff.

Ah, by the way, the features shown in this video are not available in Copter-4.0.3 (or 4.0.4). Youā€™ll need to load ā€œlatestā€ (aka ā€œmasterā€) which can be loaded onto the autopilot from MPā€™s Install Firmware screen after pressing ā€œCtrl-Qā€. Alternatively the ā€œlatestā€ firmware for a Pixhawk1 can be downloaded from here. Please be careful with ā€œlatestā€ though because it hasnā€™t gone through beta testing so itā€™s not as safe as beta or stable.

Iā€™ll try it with Roverā€™s latest firmware.Thanks for reminding me.
When I connected mulit-vehicles.Could I use Lua Scripts to get other vehicles data,such as GPS singal?

@zthcool, not yet Iā€™m afraid. I think it might be possible after this PR goes in: https://github.com/ArduPilot/ardupilot/pull/13660

Iā€™ll continue to focus on the PR.Thanks for guiding me
Now I find MP support Python Scripts.I looked through Script.cs and CurrentState.cs files,didnā€™t find info about multi-vehicles operation options.Is there any possible to realize get other vehicles data?And how does MP get these multi-vehicles parameters meanwhile?

Hi @zthcool, Iā€™m afraid I have no idea about the python support in MP. Perhaps @meee1 has some adviceā€¦