mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-23 14:17:35 +08:00
mavlink timesync avoid unintended integer divide
- fixes Coverity CID 306260
This commit is contained in:
committed by
Lorenz Meier
parent
a90c7659ad
commit
99b9eaea68
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user