From b7404ad6c15231bef2a03add05f6b65e0138d24c Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Thu, 18 Jan 2018 10:23:44 +0100 Subject: [PATCH] vmount: fix new input getting lost in throttling This fixes the case where a new gimbal input gets lost in the output throttling. This is required because an input is potentially set only once and then not computed again. In the failure case, control_data is set to nullptr in subsequent calls and therefore not used for the output calculation ever. --- src/drivers/vmount/vmount.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/drivers/vmount/vmount.cpp b/src/drivers/vmount/vmount.cpp index 84f009d6f3..2845bc0b63 100644 --- a/src/drivers/vmount/vmount.cpp +++ b/src/drivers/vmount/vmount.cpp @@ -352,6 +352,8 @@ static int vmount_thread_main(int argc, char *argv[]) } } + bool input_changed = false; + if (thread_data.input_objs_len > 0) { //get input: we cannot make the timeout too large, because the output needs to update @@ -373,11 +375,17 @@ static int vmount_thread_main(int argc, char *argv[]) if (control_data_to_check != nullptr || already_active) { control_data = control_data_to_check; last_active = i; + + if (!already_active) { + input_changed = true; + } } } hrt_abstime now = hrt_absolute_time(); - if (now - last_output_update > 10000) { // rate-limit the update of outputs + // Rate-limit the update of outputs, unless we just changed inputs because we wouldn't + // want to miss the new control data. + if (now - last_output_update > 10000 || input_changed) { last_output_update = now; //update output