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

Multi waypoint mission option #6765

Merged
merged 40 commits into from
Nov 6, 2021

Conversation

breadoven
Copy link
Collaborator

@breadoven breadoven commented Mar 30, 2021

PR adds the ability to load multiple WP missions together from the CLI. Once loaded and saved from the CLI an individual mission can be selected using the nav_multi_waypoint_mission_index setting with the mission loaded in the usual way prior to flight. nav_multi_waypoint_mission_index can be changed using OSD CMS input.

Example CLI WP input:

wp 0 1 lat lon alt 0 0 0 0
wp 1 1 lat lon alt 0 0 0 0
wp 2 1 lat lon alt 0 0 0 0
wp 3 4 0 0 0 0 0 0 165
wp 0 1 lat lon alt 0 0 0 0
wp 1 1 lat lon alt 0 0 0 0
wp 2 1 lat lon alt 0 0 0 0
wp 3 1 lat lon alt 0 0 0 0
wp 4 4 0 0 0 1 0 0 165
wp 0 1 lat lon alt 0 0 0 0
wp 1 1 lat lon alt 0 0 0 0
wp 2 1 lat lon alt 0 0 0 165

The above WP entries are input to the CLI successively and then saved using the WP save command as usual. If multi_waypoint_mission_index is set to 2 then the following mission will be loaded:

wp 0 1 lat lon alt 0 0 0 0
wp 1 1 lat lon alt 0 0 0 0
wp 2 1 lat lon alt 0 0 0 0
wp 3 1 lat lon alt 0 0 0 0
wp 4 4 0 0 0 1 0 0 165

PR also adds a WP mission entry to the Arming screen, after the Craft name, showing the selected mission number. total missions available and the number of WPs in the selected mission. If the selected mission number is higher than the number of missions then no mission is loaded and the Arming screen mission message indicates the selected mission is out of range. nav_multi_waypoint_mission_index resets to 1 when new missions are loaded and saved in the CLI.

@avsaase
Copy link
Member

avsaase commented Mar 31, 2021

Does this work together with the configurator? @ArnoTlse is working on improving the mission control tab. Maybe this could be incorporated?

@breadoven
Copy link
Collaborator Author

breadoven commented Mar 31, 2021

Works fine with Configurator, loads the selected mission when you load from EEPROM. Needs to be done twice because the first attempt fails but this is an existing bug. Also saves a single mission correctly.

Easy to test anyway, just play around with the CLI WP settings to see what's loading. Only thing missing perhaps is the ability to see the full list of WPs loaded. You can see the full list after you've entered it but after rebooting you only see WPs in the selected mission when you enter WP in the CLI since they're the only ones loaded in posControl.waypointList.

@stronnag
Copy link
Collaborator

To be useful fo rmost user who plan mission via graphical planner rather than arcane CLI stanza; it needs to be integrated into the MSP_WP_MISSION_LOAD / MSP_WP_MISSION_SAVE functions where there is currently a not yet implemented / unused index parameter.

Possibly also extending MSP_WP_GETINFO to provide info on the number of populated slots.

@ArnoTlse
Copy link

Hi @avsaase

I'll note that point in my list todo for inav configurator mission planner tab : #1181 to keep track on it once MSP code will be updated with such features as mentionned by @stronnag.

Arno

@stronnag
Copy link
Collaborator

stronnag commented Apr 1, 2021

I'm not sure how practical fully implementing indexed MSP_WP_MISSION_LOAD / MSP_WP_MISSION_SAVE would be:

  • The flash is read / written in its entirety, not by individual elements
  • Having MSP update an index with this current implementation requires reassembling the whole stored set.
  • There is still an overall limit of 60 waypoints, regardless.

@breadoven
Copy link
Collaborator Author

This is really a basic implementation of an idea for multiple missions. Wouldn't be any use if you typically use more than 30 WPs in a mission. However, if you're using less than 20 then it does provide an option to have easy access to more than a single mission without the need to use other tools to load new missions in the field.

I'm not sure the CLI is that arcane given it's the only way to change numerous settings, sometimes quite basic ones at that, The biggest part of setting up a mission is entering it in something like Configurator Mission Control and changing the various settings per WP. Copying the CLI WP output for each mission from the CLI and pasting it into a multi WP file then ultimately pasting all the entries back into the CLI to set up the multi mission is the easy part.

I had a cursory look at the MSP stuff and the way Configurator works with it loading and saving missions. I also came to the conclusion that using a mission number index wouldn't help because the multi mission input relies on looking for the end of mission flag (165) rather than counting mission entries based on an index. The mission index is perhaps more relevant for a multi dimensional posControl.waypointList ?.

If you consider the multi mission entry is essentially a "single" mission file but with multiple end of mission flags then that would be an easier way of handling it. As far as I can see Mission Control doesn't use the 165 flag to indicate the end of a mission, it counts WP entries instead. It could work with multi mission entries If it used the 165 flag to process WP entries although in that case it would need the total number of WP entries in the multi mission file to work, so just a multi mission total WP count variable adding perhaps. In fact when I was playing with this I set the total number of WPs to the total for all missions. This loaded all the missions correctly in Mission Control ... but all joined together as one huge mission (would have needed a big battery).

Make all multi mission WPs visible  in CLI mode
Improve handling single WP missions. Block RTH single WP missions from causing problem finding end of multi mission entry.
Fix arm screen message
src/main/fc/settings.yaml Outdated Show resolved Hide resolved
- Check number missions loaded during boot with option to load selected mission at the same time
- Mission selection from OSD mission field using stick commands
- Added total number WPs in all missions
@breadoven
Copy link
Collaborator Author

breadoven commented May 5, 2021

Updated:

  1. Added ability to use stick commands (Roll right and Left) to change selected mission index in OSD mission info field before loading using existing mission load stick command (easier than using CMS)
  2. Number of missions in multi mission entry checked at boot with option to load selected mission at the same time. This is the same option included in Automatically load waypoints during FC boot #6612. It's been added to this PR because loadNonVolatileWaypointList needs to be called anyway to check the total number of missions so can load the currently selected mission at the same time if required.
  3. Added poscontrol variable for total number WPs in all missions (not sure how much use this is if end of mission flag is used to determine number missions and WPs instead)
  4. Added ability to unload all missions by setting mission index to 0

Changed to load all missions always and only load selected mission on ARM
protect against incorrect mission index setting
Inhibit stick selection for single mission.
Correct setting description.
@breadoven
Copy link
Collaborator Author

If this is considered a worthwhile addition to INAV then it's now working as required so good to merge. Configurator Mission Control support for it is also complete and good to merge, iNavFlight/inav-configurator#1381.

The basic way this functions in the final version is as follows:

Multi missions are handled as a "single" mission (WP numbers sequential from start to end of all mission entries) but with multiple mission end flags. Configurator Mission Control now reads the WP flag from the FC or .mission file allowing it to display individual missions correctly (Mission files are saved with the flag included).

On NVM load when disarmed all multi mission WP entries are loaded into posControl.waypointList. The selected mission position and size is marked during load based on end flag. It is only set as the active mission on Arming ... by moving it to the start of posControl.waypointList. This gives Configurator Mission Control access to all missions whilst disarmed. Once loaded at arming the selected mission remains set until you disarm and load another mission. The required mission is selected either by setting the mission index in CMS or by using the roll stick to change the selected index in the OSD Mission field.

Jump sanity checking still works but only at the point of Arming if the selected mission isn't the first mission (single missions work as before). Distance to first WP sanity checking works as before whilst disarmed.

Example mission:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mission>
	<version value="2.3-pre8"/>
	<mwp cx="-3.2869291" cy="54.5722109" home-x="0" home-y="0" zoom="14"/>
	<missionitem no="1" action="WAYPOINT" lat="54.5722109" lon="-3.2869291" alt="50" parameter1="0" parameter2="0" parameter3="0" flag="0"/>
	<missionitem no="2" action="WAYPOINT" lat="54.5708178" lon="-3.2642698" alt="50" parameter1="0" parameter2="0" parameter3="0" flag="0"/>
	<missionitem no="3" action="WAYPOINT" lat="54.5698227" lon="-3.2385206" alt="50" parameter1="0" parameter2="0" parameter3="0" flag="165"/>
	<missionitem no="4" action="WAYPOINT" lat="54.5599696" lon="-3.2958555" alt="50" parameter1="0" parameter2="0" parameter3="0" flag="0"/>
	<missionitem no="5" action="WAYPOINT" lat="54.5537978" lon="-3.2958555" alt="50" parameter1="0" parameter2="0" parameter3="0" flag="0"/>
	<missionitem no="6" action="WAYPOINT" lat="54.5547933" lon="-3.2864141" alt="50" parameter1="0" parameter2="0" parameter3="0" flag="0"/>
	<missionitem no="7" action="WAYPOINT" lat="54.5597705" lon="-3.2695913" alt="50" parameter1="0" parameter2="0" parameter3="0" flag="0"/>
	<missionitem no="8" action="WAYPOINT" lat="54.555291" lon="-3.2598066" alt="50" parameter1="0" parameter2="0" parameter3="0" flag="0"/>
	<missionitem no="9" action="JUMP" lat="0" lon="0" alt="0" parameter1="1" parameter2="0" parameter3="0" flag="165"/>
	<missionitem no="10" action="WAYPOINT" lat="54.5714148" lon="-3.2501936" alt="50" parameter1="0" parameter2="0" parameter3="0" flag="165"/>
</mission>
#wp 10 valid
wp 0 1 545722109 -32869291 5000 0 0 0 0
wp 1 1 545708178 -32642698 5000 0 0 0 0
wp 2 1 545698227 -32385206 5000 0 0 0 165
wp 3 1 545599696 -32958555 5000 0 0 0 0
wp 4 1 545537978 -32958555 5000 0 0 0 0
wp 5 1 545547933 -32864141 5000 0 0 0 0
wp 6 1 545597705 -32695913 5000 0 0 0 0
wp 7 1 545552910 -32598066 5000 0 0 0 0
wp 8 6 0 0 0 0 0 0 165
wp 9 1 545714148 -32501936 5000 0 0 0 165
wp 10 0 0 0 0 0 0 0 0
wp 11 0 0 0 0 0 0 0 0
wp 12 0 0 0 0 0 0 0 0
......

@breadoven breadoven requested review from DzikuVx and stronnag November 2, 2021 22:18
@stronnag
Copy link
Collaborator

stronnag commented Nov 3, 2021

Thanks, I'll take a look at this over the weekend.

Copy link
Collaborator

@stronnag stronnag left a comment

Choose a reason for hiding this comment

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

I've tested this extensively (via adding support to mwp) and have had no issues.
It seems a bit "inelegant", but as we have no other solution without fine control of config flash I/O, I see no other or better solution. And this has the benefit of conserving resources on the FC side.
Monumental piece of work pulling all this together.

@DzikuVx DzikuVx added this to the 4.0 milestone Nov 6, 2021
@DzikuVx DzikuVx added the Release Notes Add this when a PR needs to be mentioned in the release notes label Nov 6, 2021
@DzikuVx DzikuVx merged commit 3dad1d2 into iNavFlight:master Nov 6, 2021
@breadoven breadoven deleted the abo_multi_wp_mission_option branch November 8, 2021 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready to merge Release Notes Add this when a PR needs to be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants