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_Mission: better deal with home being in index 0. #29071

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

Conversation

IamPete1
Copy link
Member

@IamPete1 IamPete1 commented Jan 14, 2025

This is a result of the discussion on #29039. The two key things are:

  • AP_Mission::add_cmd will add home if needed and then add the passed in command so that the passed in command is always added and not lost in index 0.
  • AP_Mission::replace_cmd will not replace the command in index 0, but it does still return true in that case.
  • AP_Mission::write_home_to_storage will set _cmd_total to 1 if it is 0.

There are also a number of clean ups and bug fixes:

  • new present() method on mission which consolidates all the places that were trying to tell if there was a mission. We had been using mission.num_commands() > 1 and mission.num_commands() <= 1 or mission.num_commands() < 2 for not present. This also replaces mission.num_commands() == 0 which copter was using incorrectly for AUX_FUNC::SAVE_WP
  • Fixes the lack of a workaround in copter AUX_FUNC::SAVE_WP and remove the need for the workaround in rover AUX_FUNC::SAVE_WP
  • AHRS now directly calls mission write_home_to_storage so it will always be upto date and we don't have to do it in rover and plane manually.

The AHRS auto set of the home mission item is the only one users might notice, this was only done on plane and rover previously. Because it now also updates _cmd_total it is now more likely to be 1 than 0 with no mission loaded.

@IamPete1
Copy link
Member Author

I have updated the copter RecordThenPlayMission test to expect the takeoff as the first item (the test was enforcing that adding the takeoff did not work).

@IamPete1
Copy link
Member Author

IamPete1 commented Jan 14, 2025

I have updated mission write to not change _last_change_time_ms if index 0 is being written, none of the things checking it look at index 0 in an case so this ensures we not triggering things to re-fetch the mission now we do write to index 0 more often.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant