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

Use a uniform distribution to drop messages in lossy test #1827

Merged
merged 2 commits into from
Jun 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/integration_tests/mission_transfer_lossy.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#include <iostream>
#include <future>
#include <atomic>
#include "log.h"
#include <future>
#include <iostream>
#include <random>

#include "integration_test_helper.h"
#include "log.h"
#include "mavsdk.h"
#include "plugins/mission/mission.h"
#include "plugins/mavlink_passthrough/mavlink_passthrough.h"
#include "plugins/mission/mission.h"

using namespace mavsdk;

static void set_link_lossy(std::shared_ptr<MavlinkPassthrough> mavlink_passthrough);
static std::vector<Mission::MissionItem> create_mission_items();
static bool should_keep_message(const mavlink_message_t& message);

static std::atomic<size_t> _lossy_counter{0};
static std::default_random_engine generator;
static std::uniform_real_distribution<double> distribution(0.0, 1.0);

TEST_F(SitlTest, PX4MissionTransferLossy)
{
Expand Down Expand Up @@ -70,7 +73,7 @@ bool should_keep_message(const mavlink_message_t& message)
// message.msgid == MAVLINK_MSG_ID_MISSION_ACK || FIXME: we rely on ack
message.msgid == MAVLINK_MSG_ID_MISSION_COUNT ||
message.msgid == MAVLINK_MSG_ID_MISSION_ITEM_INT) {
should_keep = (_lossy_counter++ % 10 != 0);
should_keep = distribution(generator) < 0.95;
}
return should_keep;
}
Expand Down