manual_control: don't accept outdated input

This commit is contained in:
Julian Oes 2021-06-16 10:40:41 +02:00 committed by Matthias Grob
parent 4d00a56230
commit 2c0fc686a7
1 changed files with 8 additions and 2 deletions

View File

@ -47,8 +47,14 @@ void ManualControlSelector::update_time_only(uint64_t now)
void ManualControlSelector::update_manual_control_input(uint64_t now, const manual_control_input_s &input, int instance)
{
// This method requires the current timestamp explicitly in order to prevent weird cases
// if the timestamp_sample of some source is invalid/wrong.
// This method requires the current timestamp explicitly in order to prevent the case
// where the timestamp_sample of some source is already outdated.
if (now >= input.timestamp_sample && now - input.timestamp_sample > _timeout) {
_setpoint.valid = false;
_instance = -1;
return;
}
// If previous setpoint is timed out, set it invalid, so it can get replaced below.
update_time_only(now);