Lua Scripts using Velocity Control


This is a test of Lua scripts controlling a Copter using a velocity controller so that it flies a vertically oriented circle (like a Ferris Wheel or lollipop). The purpose of making this was to provide a simple example of the growing power of ArduPilot’s Lua scripting feature (originally developed by Michael du Breuil).

ArduPilot is already very powerful and flexible but even so many users want to customise their vehicle’s behaviour in some way, often in a way that is too specific to their setup for us to include in the core flight code. Lua scripts add a relatively safe and easy way for users to make these customisations without having to add a companion computer or learn C++.

BTW, the frame is a Hexsoon EDU450 with a Hex Cube Orange autopilot running ArduPilot Copter-4.1.0-dev (with this PR applied) and the exact script can be seen here.

8 Likes

This is a awesome video to show full detail :nerd_face: how to configure… I really like it.
Thank you sir for this useful post share with us , this is very useful for me in future :yum:

Thank you soo much :slightly_smiling_face:

2 Likes

Thank you Randy,im not quite ready to test this yet but more fun for the warmer days

1 Like

@rmackay9 Thanks, nice examples of scripting. But I think the link to the vertical circle script should be:

Hey @rmackay9
Not able to enable scripting on Cube Purple. Getting the following message.

@Mallikarjun_SE,

Yes, scripting takes up quite a bit of memory. On Cube Orange (and probably Holybro Durandal) it’s fine but on most other boards, if you’re running Copter, you’ll need to disable some other features. Try these:

  • TERRAIN_ENABLE = 0 (turn off the SRTM database used for terrain following during missions)
  • EK2_IMU_MASK = 1 (turn off the backup EKF)

Hey @rmackay9
I use terrain follow all the time since I stay at a hilly region. EK2_IMU_MASK=1 is default for CubePurple.
I switched from Master to stable. It got initialized.
Thank you.

1 Like

@Mallikarjun_SE,

OK great. Scripting is being actively enhanced these days though so you’ll find that the features available to scripting with Copter-4.0.3 are a bit less than we have in master. Anyway, thanks for trying it out!

Hi Randy is this the camera please,https://www.mouser.co.uk/ProductDetail/Intel/82637BRPLHV?qs=u16ybLDytRb4k4WMtRhqgg%3D%3D dogie no likie Randy treat money gone on quad lol if this is the one will order tomorrow

@MartyMcFly,

Yes, that’s the camera I used in this recent video. You’ll need an RPI4 to go with it and you might want to get one of Stephen Dade’s PiConnectLite boards to make wiring easier but this is optional

1 Like

im strugling getting info on the PI14 its coming up here as a form for the goverment,

https://www.raspberrypi.org/products/raspberry-pi-4-model-b/

1 Like

Thankyou Corrado_Steri

Hey @rmackay9
Couldn’t get scripting working on Cube purple with AC4.0.3 stable even with terrain disabled. I can’t find the scripts folder at all in MAVFtp. I bought couple of Cube Purples for ground tests and other beta tests, But It already feels outdated. Scripts don’t run, Compass is not probed by default to have Fast sampling. Looks like H7 is the good investment.
Update: No luck with latest Dev with terrain disabled.

1 Like

you will have to make the scripts folder

1 Like

It said creating the directory failed. Should I make the folder on the sd card manually?

1 Like

It should be possible via MAVFtp, try it manually and see if scripts will work at all, the simple loop is the best for debugging.

2 Likes

No luck after creating folder. Scripts aren’t getting initialized.



Cube Purple.param (17.9 KB)

you should get a message on boot, you will have to be quick on the connect to catch it.

1 Like

Yep! Got Hello World. I’ll other scripts.

1 Like