Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LUA: Mission Rotation - Up to 10 selectable missions via tx switch #28804

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

robustini
Copy link
Contributor

@robustini robustini commented Dec 4, 2024

This LUA script is an evolution on the MissionSelector.LUA.
Allows you to select up to 10 missions, either while arming or in the unarmed state.
It requires that an RCx_OPTION be set to a scripting value and must match the one inside the LUA.
The scripts should be installed in the SCRIPTS folder on the MicroSD, and the mission files in the root.
The mission file called mission0.txt (the default mission) must exist and is loaded at boot, if the script does not find it it stops working.
The other mission files should have the same name with only the number changed, from 1 to 9, example mission8.txt.
To load to the next mission file just bring AUX switch from low to high for no more than three seconds, each switch loads the next mission file in numerical order.
If the next mission file numerically does not exist load the next one, at the end of the rotation it returns to load mission0.txt.
If AUX is held at high state for more than three seconds the script will restart by loading mission0.txt.
If a mission switch is attempted in AUTO flight mode, a warning "Cannot switch missions in AUTO mode" will be shown and no operation will be performed.
If try to load the script and the flight mode is AUTO you will get a message “The script cannot be loaded in AUTO mode”
Provides for sending messages under any condition, load or error.

Classic example of use, i.e. how I usually use it:

  • mission0.txt is my automatic takeoff mission with home setting at a different point from arming followed by RTL, this way after manually launching my fpv plane I can put on my goggles, exit RTL and execute my flight
  • mission1.txt is a full circuit mission for automatic landing, I load it if I want Ardupilot to perform an automated landing from the R side of the runway. This comes in handy, for example, if video transmission is interrupted and visibility on the ground is not optimal
  • mission2.txt is like mission1.txt but executes the circuit for landing runway L the other mission files I use to perform specific automated flights
  • some other mission files to run special routes

In my case if any failsafe intervenes the chosen mission is then executed.
In this way by pre scheduling the appropriate missions for the location where I fly I can afford to handle any emergencies without using GCS, simply choosing with the script the most appropriate mission, and in case changing it on the fly.
Thanks to @IamPete1 for help on intercepting the vehicle type.
Of course, suggestions, corrections and implementations are welcome!

- for each loaded mission it also shows the number of events it contains
- cosmetic
- simplified selection of vehicle type and AUTO mode
- removed redundant code for AUTO mode calculation
- cleaned up code for better readability
- LUA management with a channel assigned to scripting
- script management with a channel assigned to scripting
- fixed error loading default mission several times in RC cases always at high state
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant