Skip to content

Commit 887ca6d

Browse files
committed
ManualControlSelector: address invalid prioritized input and don't check if sample is from the future
1 parent 461433d commit 887ca6d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/modules/manual_control/ManualControlSelector.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ void ManualControlSelector::updateValidityOfChosenInput(uint64_t now)
4343

4444
void ManualControlSelector::updateWithNewInputSample(uint64_t now, const manual_control_setpoint_s &input, int instance)
4545
{
46-
if (isRc(input.data_source)) { _timestamp_last_rc = input.timestamp_sample; }
46+
if (input.valid) {
47+
if (isRc(input.data_source)) { _timestamp_last_rc = input.timestamp_sample; }
4748

48-
if (isMavlink(input.data_source)) { _timestamp_last_mavlink = input.timestamp_sample; }
49+
if (isMavlink(input.data_source)) { _timestamp_last_mavlink = input.timestamp_sample; }
50+
}
4951

5052
// First check if the chosen input got invalid, so it can get replaced
5153
updateValidityOfChosenInput(now);
@@ -70,7 +72,6 @@ void ManualControlSelector::updateWithNewInputSample(uint64_t now, const manual_
7072
bool ManualControlSelector::isInputValid(const manual_control_setpoint_s &input, uint64_t now) const
7173
{
7274
// Check for timeout
73-
const bool sample_from_the_past = now >= input.timestamp_sample;
7475
const bool sample_newer_than_timeout = now < input.timestamp_sample + _timeout;
7576

7677
// Check if source matches the configuration
@@ -107,7 +108,7 @@ bool ManualControlSelector::isInputValid(const manual_control_setpoint_s &input,
107108
break;
108109
}
109110

110-
return sample_from_the_past && sample_newer_than_timeout && input.valid && match;
111+
return sample_newer_than_timeout && input.valid && match;
111112
}
112113

113114
manual_control_setpoint_s &ManualControlSelector::setpoint()

0 commit comments

Comments
 (0)