Skip to content

Commit

Permalink
ManualControlSelectorTest: add constantly outdated samples case
Browse files Browse the repository at this point in the history
Reviewing the code I saw this case arising from the order things
get checked.
  • Loading branch information
MaEtUgR committed Jun 15, 2021
1 parent b8f3172 commit 962e2b9
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/modules/manual_control/ManualControlSelectorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,26 @@ TEST(ManualControlSelector, RcTimeout)
EXPECT_FALSE(selector.setpoint().valid);
EXPECT_EQ(selector.instance(), -1);
}

TEST(ManualControlSelector, RcOutdated)
{
ManualControlSelector selector;
selector.set_rc_in_mode(0);
selector.set_timeout(500_ms);

uint64_t timestamp = some_time;

manual_control_input_s input {};
input.data_source = manual_control_input_s::SOURCE_RC;
input.timestamp_sample = timestamp - 600_ms; // First sample is already outdated
selector.update_manual_control_input(timestamp, input, 0);

EXPECT_FALSE(selector.setpoint().valid);
EXPECT_EQ(selector.instance(), -1);

// If we update again it should still not get accepted
selector.update_manual_control_input(timestamp, input, 0);

EXPECT_FALSE(selector.setpoint().valid);
EXPECT_EQ(selector.instance(), -1);
}

0 comments on commit 962e2b9

Please sign in to comment.