Skip to content

Commit

Permalink
Add tests for behavior with override switches flipped
Browse files Browse the repository at this point in the history
  • Loading branch information
BillThePlatypus committed Apr 1, 2020
1 parent 757cfcb commit 0db8a3e
Showing 1 changed file with 45 additions and 3 deletions.
48 changes: 45 additions & 3 deletions test/command_manager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ class CommandManagerTest : public ::testing::Test
rf.state_manager_.clear_error(rf.state_manager_.state().error_codes); // Clear All Errors to Start
rf.params_.set_param_int(PARAM_CALIBRATE_GYRO_ON_ARM, false);

for (int i = 0; i < 8; i++)
{
for (int i = 0; i < 4; i++)
rc_values[i] = 1500;
}
for (int i=4;i<8;i++)
rc_values[i]=1000;
rc_values[2] = 1000;

rf.params_.set_param_int(PARAM_MIXER, Mixer::PASSTHROUGH);
Expand Down Expand Up @@ -465,6 +465,48 @@ TEST_F (CommandManagerTest, OffboardCommandMuxLag)
EXPECT_EQ(override, 0x20); // Throttle override only
}

TEST_F (CommandManagerTest, RCAttitudeOverrideSwitch)
{
stepFirmware(1100000); // 1.1s Get past LAG_TIME
rf.params_.set_param_int(PARAM_RC_ATTITUDE_OVERRIDE_CHANNEL, 4);
rf.params_.set_param_int(PARAM_RC_THROTTLE_OVERRIDE_CHANNEL, -1);
rf.params_.set_param_int(PARAM_RC_OVERRIDE_TAKE_MIN_THROTTLE, false);
setOffboard(offboard_command);
stepFirmware(50000); // 50ms

uint16_t override = rf.command_manager_.get_rc_override();
EXPECT_EQ(override, 0);

rc_values[4] = 2000;
board.set_rc(rc_values);

stepFirmware(50000); // 50ms
override = rf.command_manager_.get_rc_override();
EXPECT_EQ(override, 1);

}

TEST_F (CommandManagerTest, RCThrottleOverrideSwitch)
{
stepFirmware(1100000); // 1.1s Get past LAG_TIME
rf.params_.set_param_int(PARAM_RC_ATTITUDE_OVERRIDE_CHANNEL, -1);
rf.params_.set_param_int(PARAM_RC_THROTTLE_OVERRIDE_CHANNEL, 4);
rf.params_.set_param_int(PARAM_RC_OVERRIDE_TAKE_MIN_THROTTLE, false);
setOffboard(offboard_command);
stepFirmware(50000); // 50ms

uint16_t override = rf.command_manager_.get_rc_override();
EXPECT_EQ(override, 0);

rc_values[4] = 2000;
board.set_rc(rc_values);

stepFirmware(50000); // 50ms
override = rf.command_manager_.get_rc_override();
EXPECT_EQ(override, 2);

}

TEST_F (CommandManagerTest, StaleOffboardCommand)
{
stepFirmware(1100000); // Get past LAG_TIME
Expand Down

0 comments on commit 0db8a3e

Please sign in to comment.