Lua Scripts using Velocity Control

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…

Thank you again,I am looking through example2.py in the scripts MP folder.It seems can promote my problems

1 Like

I found something about how to get other vehicle data.For example,I connected two vehicles,one sysid is 2,the other is 3,if you want to get “lat/lng” data .just imput lat = MAV.MAVlist[sysid, compid].cs.lat
lng = MAV.MAVlist[sysid, compid].cs.lng in Python Scripts

2 Likes

Hi guys!

I have a problem uploading scripts files:

when I tried to upload (or download) a script, an error message appears

at the end, the script appear into the folder but it is empty…

I only can get put the scripts into the folder manually but I need to do that via telemetry!!

Also sometimes appear a error message in Mission Planner that may be related to this ( I am not sure)

This error message appear since I updated Mission Planner to the last versión to get the MAVftp option (because I can’t see it in the older versión I had installed)

Any ideas??

Finally I got upload the script, but only if the size is smaller than 228…I don’t understand why…

Any ideas???

Excuse me,could you teach me create the folder called scripts

clicking rigth mouse button under the folder APM and select the “New folder” option, That’s all.

1 Like

I am using ArduCopter version V4.1.0-dev firmware on Pixhawk, new examples added to this version mostly working fine but i want to add new bindings for lua scripting, this documentation for How to Add New Bindings does not seems to be updated according to the master branch https://ardupilot.org/copter/docs/common-lua-scripts.html#how-to-add-new-bindings. I wanted to know how can i add more mavlink commands as new bindings to run with lua script.

@Notorious7,

The documentation is a little out of date but not too bad. The first two lines are still valid,

  • Find the method or function you would like to expose to Lua. For example if you wanted to expose an additional feature of AHRS you would first find the method within libraries/AP_AHRS/AP_AHRS.h
  • Edit the libraries/AP_Scripting/generator/description/bindings.desc and add a new line in the appropriate section for the method.

But this last one is no longer necessary because it’s done automatically when the ArduPilot vehicle code is compiled.

  • Open a command line prompt and cd to the /libraries/AP_Scripting/generator directory and type “make run”

By the way, mavlink is not really involved for lua scripts. Lua scripts have direct access to the flight code so they don’t need to use mavlink.

i see, thanks for helping, just curious to know if there’s any way around to run lua scripting feature in flight controllers with 1MB flash, i just want to automate a drone movements in guided mode by giving drone a set of positions stored in a text file, i don’t want to use any other features apart from this functionality for the moment

Hi rmackay9

Finally I got upload the script, but only if the size is smaller than 228…I don’t understand why…

Any ideas???