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

Robustify mission upload/download #230

Merged
merged 3 commits into from
Feb 1, 2018
Merged

Conversation

julianoes
Copy link
Collaborator

@julianoes julianoes commented Jan 18, 2018

This fixes the case where a mission item gets lost from the autopilot to
DroneCore and we need to request the same one again.

Previously, we just requested the next one, essentially skipping the one
we missed. This then lead the autopilot to respond with a failure
because the wrong sequence was requested.

These fixes go together with:
mavlink/qgroundcontrol#6059
PX4/PX4-Autopilot#8750

@julianoes julianoes changed the title Fix mission download failure case Robustify mission upload/download Jan 24, 2018
@@ -23,6 +23,9 @@ static std::shared_ptr<MissionItem> add_mission_item(double latitude_deg,
static void compare_mission_items(const std::shared_ptr<MissionItem> original,
const std::shared_ptr<MissionItem> downloaded);

// Set to 1 to test with 1200 mission items.
#define MANY_ITEMS_TEST 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not having a variable (boolean) instead of an ifdef? Ifdefs tend to end up with code that does not compile...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right, fixed in b99c779.

@@ -741,15 +762,16 @@ void MissionImpl::set_current_mission_item_async(int current, Mission::result_ca
_result_callback = callback;
}

void MissionImpl::upload_mission_item(uint16_t seq)
void MissionImpl::upload_next_mission_item()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd rather pass the item id as a parameter (as it was done before) and have this function const. So that we know it doesn't have side effects.

@@ -96,7 +95,9 @@ void MissionImpl::process_mission_request_int(const mavlink_message_t &message)
return;
}

upload_mission_item(mission_request_int.seq);
_next_mission_item_to_upload = mission_request_int.seq;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it really need to be a member? Seems to be part of the fix somehow, but I'm not sure I understand =/.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For retransmission you need to keep track of what the next mission item to upload is. This is done using this member.

This allows to test with many mission items but instead of a define we
use a variable, so that we can catch compile errors.
In case any of the MISSION_ITEM or MISSION_REQUEST messages get lost on
the way, we need to retry a couple of times.

We do this with two different timeouts, one for the passive case where
the autopilot pulls (requests) mission items from us and an active case
with a lower timeout where we pull mission items.
@julianoes
Copy link
Collaborator Author

@JonasVautherin thanks for reviewing. I realized that the retransmission logic when uploading was incorrect. Instead of re-pushing items we just need to wait for the autopilot to pull them.

I've reworked the commits and it is now one commit implementing the retransmission. Your concerns with the member variable is resolved as well.

@julianoes julianoes merged commit 21599e8 into develop Feb 1, 2018
@julianoes julianoes deleted the fix-mission-download branch February 1, 2018 14:55
dlech pushed a commit to dlech/MAVSDK that referenced this pull request Jan 14, 2022
Remove obsolete ListRunningPlugins and add SetMavlinkTimeout to core
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.

2 participants