Skip to content

Commit

Permalink
Merge pull request #1827 from mavlink/improve-mission-transfer-lossy
Browse files Browse the repository at this point in the history
Use a uniform distribution to drop messages in lossy test
  • Loading branch information
julianoes authored Jun 30, 2022
2 parents 582b0d3 + 83d5e5d commit 9d65f21
Showing 1 changed file with 9 additions and 6 deletions.
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

0 comments on commit 9d65f21

Please sign in to comment.