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

AP_Scripting: added applet SM_SwitchMission #22348

Closed

Conversation

WillyZehnder
Copy link
Contributor

Script for switching of missions that are saved on SD-card 'on the fly'.
Selection and loading can be done by one of two different methods (multi-position-switch or push-button).
The amount of missions is theoretically unlimited.
Convenient preparation of environment like searching sufficient table_key, finding correct sub-directory for SITL or SD-card and counting available and checking sufficient number of missions.

@timtuxworth
Copy link
Contributor

What an absolutely brilliant idea!

local SCRIPT_NAME = 'SM' -- abbreviation of scriptname for messages on GCS
local SUB_DIR_APM = '/APM/scripts'-- path to scripts on SD-card
local SUB_DIR_SITL = './scripts' -- path to scripts when using SITL
local SUB_DIR_MISSIONS = 'missions' -- subdirectory below scripts-directory where the mission-files are stored
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps "missions" should be at the APM root, rather than buried under "scripts"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to have the missions near scripts - but let's see what the developers strategy is.

@WillyZehnder
Copy link
Contributor Author

What an absolutely brilliant idea!

Thank you Tim :o)

@IamPete1
Copy link
Member

IamPete1 commented Dec 5, 2022

If it works and someone else can give it a try I'm happy to approve.

@WillyZehnder
Copy link
Contributor Author

WillyZehnder commented Dec 6, 2022

If it works and someone else can give it a try I'm happy to approve.

I tested a pre-version in real plane-flight and the latest version of course in SITL.
In the moment a real test of the latest version is not possible because of very nasty weather and 1°C(34°F).

The version without script-specific parameters is still commented by some users:
https://discuss.ardupilot.org/t/switch-missions-on-the-fly/92106/31

But I will ask for test-comments of the current version.

@WillyZehnder
Copy link
Contributor Author

If it works and someone else can give it a try I'm happy to approve.

I improved it and tested the lua in SITL - all is working fine.
McKey tested it in Rover with positive feedback.
https://discuss.ardupilot.org/t/switch-missions-on-the-fly/92106/50

@WillyZehnder WillyZehnder force-pushed the ScriptSwitchMission branch 2 times, most recently from 735dbce to f796a1e Compare December 20, 2022 14:19
@WillyZehnder
Copy link
Contributor Author

@IamPete1 Hi Pete, now all should be done.

@WillyZehnder
Copy link
Contributor Author

After rebase, it seems the lua-bug of receiving a correct handle when opening a not existing file for reading is fixed.
But that leads to an error in my script because of using a nil-handle.
So I had to rework the script and could simplify the check after file:io.open.

@WillyZehnder
Copy link
Contributor Author

https://discuss.ardupilot.org/t/switch-missions-on-the-fly/92106/58

@IamPete1 What else is necessary to merge (disregarding of a rebase)?

WillyZehnder and others added 2 commits May 30, 2023 19:22
Co-authored-by: Peter Hall <33176108+IamPete1@users.noreply.github.com>
@IamPete1
Copy link
Member

I have rebased, we now have a scripting check in CI which this will hopefully pass. If that passes and someone else has given it a go then I'm happy (I can give it a try here too at some point).

@WillyZehnder
Copy link
Contributor Author

Thank you for rebase @IamPete1
"test scripting" passed
"I can give it a try here too at some point" - that would be great

@WillyZehnder
Copy link
Contributor Author

I'm using that feature in nearly every flight with my gliders, especially with relocation+rotation, but it seems to me, nobody is really interested in it. I really wonder why.

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.

None yet

3 participants