mavlink timesync avoid unintended integer divide

- fixes Coverity CID 306260
This commit is contained in:
Daniel Agar
2018-08-01 22:17:01 -04:00
committed by Lorenz Meier
parent a90c7659ad
commit 99b9eaea68
+1 -1
View File
@@ -107,7 +107,7 @@ MavlinkTimesync::handle_message(const mavlink_message_t *msg)
// Filter gain scheduling
if (!sync_converged()) {
// Interpolate with a sigmoid function
double progress = _sequence / CONVERGENCE_WINDOW;
double progress = (double)_sequence / (double)CONVERGENCE_WINDOW;
double p = 1.0 - exp(0.5 * (1.0 - 1.0 / (1.0 - progress)));
_filter_alpha = p * ALPHA_GAIN_FINAL + (1.0 - p) * ALPHA_GAIN_INITIAL;
_filter_beta = p * BETA_GAIN_FINAL + (1.0 - p) * BETA_GAIN_INITIAL;