Skip to content

Commit

Permalink
feat: check zero division
Browse files Browse the repository at this point in the history
Signed-off-by: TetsuKawa <[email protected]>
  • Loading branch information
TetsuKawa committed Dec 6, 2024
1 parent db51b36 commit 186b343
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ class Simple1DFilter
dev_ = dev_ + proc_dev_x_d;

// Update step
double kalman_gain = dev_ / (dev_ + obs_dev);
double kalman_gain = 1.0;
if (dev_ + obs_dev != 0) {
kalman_gain = dev_ / (dev_ + obs_dev);
}
x_ = x_ + kalman_gain * (obs - x_);
dev_ = (1 - kalman_gain) * dev_;

Expand Down

0 comments on commit 186b343

Please sign in to comment.