This repo contains a Lua script developed as part of a Bachelor's thesis project by the student Davide Altamura in collaboration with Professor Pier Luca Montessoro.
The script makes your drone execute three possible figures (square, circle and eight) by pressing a specific button on your radio. All the movements are performed using the GPS sensor, making them smooth and precise. It is fully compatible with Ardupilot's copter autopilot and it has been developed using a safety-first approach. The drone's state depends on a control switch with the following positions:
- Position 1: manual mode;
- Position 2: guided mode (only in this mode the drone can execute all the figures);
- Position 3: brake mode (hover using GPS).
Before using the Lua script, ensure that the following prerequisites are met:
- The drone should be equipped with a compatible flight controller running ArduPilot firmware. Refer to the ArduPilot documentation for installation and setup instructions here;
- Enable Lua Scripts in Ardupilot, instructions here;
- Assign two different 3-position switches to CH13 and CH14 of your radio (if you already have those channels set, you need to change the source code accordingly);
- The script is ready to use with a Radiomaster TX16s radio, depending on what radio you have you may need to change pwm values in the source code.
You can change the following values in the source code:
takeoff_altitudeto start figures at different heights;sq_dimensionto make squares of different dimensions - by default it is set to 10 (10x10);controlchto change the channel number set for the control switch - by default it is set to 14;figurechto change the channel number set to choose which figure to do - by default it is set to 13;angle_increaseto increase or decrease the circle diameter;- all the PWM values can be changed depending on what radio you have.
If you are running Lua scripts on a PixHawk4 you may need to set the parameter SCR_HEAP_SIZE to around 74000.
This project is licensed under the MIT License - see the LICENSE file for details.
- Big thank you to Professor Pier Luca Montessoro for collaborating to this project;
- Thanks to the Ardupilot community for delivering such a great product.
For any questions, feedback, or additional information, please contact @TheMaxi7


