ManualControlSelector: Allow disabling stick input

This commit is contained in:
Matthias Grob 2021-12-09 11:36:14 +01:00 committed by Daniel Agar
parent 300e439144
commit 897775f38d
2 changed files with 30 additions and 1 deletions

View File

@ -252,11 +252,12 @@ PARAM_DEFINE_INT32(COM_HOME_IN_AIR, 0);
*
* @group Commander
* @min 0
* @max 3
* @max 4
* @value 0 RC Transmitter only
* @value 1 Joystick only
* @value 2 RC and Joystick with fallback
* @value 3 RC or Joystick keep first
* @value 4 Stick input disabled
*/
PARAM_DEFINE_INT32(COM_RC_IN_MODE, 3);

View File

@ -219,6 +219,34 @@ TEST(ManualControlSelector, FirstInput)
EXPECT_EQ(selector.instance(), 0);
}
TEST(ManualControlSelector, DisabledInput)
{
ManualControlSelector selector;
selector.setRcInMode(4);
selector.setTimeout(500_ms);
uint64_t timestamp = some_time;
manual_control_setpoint_s input {};
// Reject MAVLink stick input
input.data_source = manual_control_setpoint_s::SOURCE_MAVLINK_0;
input.timestamp_sample = timestamp;
selector.updateWithNewInputSample(timestamp, input, 0);
EXPECT_FALSE(selector.setpoint().valid);
EXPECT_EQ(selector.instance(), -1);
timestamp += 100_ms;
// Reject RC stick input
input.data_source = manual_control_setpoint_s::SOURCE_RC;
input.timestamp_sample = timestamp;
selector.updateWithNewInputSample(timestamp, input, 1);
EXPECT_FALSE(selector.setpoint().valid);
EXPECT_EQ(selector.instance(), -1);
}
TEST(ManualControlSelector, RcTimeout)
{
ManualControlSelector selector;